|
If you pass an improper parameter, you can get the same error message. For instance, passing in a String where the parameter expects an Integer, or the other way around.
|
|
|
|
|
Dear Members,
I am trying to convert some Vbscripts to Vb.net GUI. Here I found a Script like this
Here I had a strange Condition
Dim strvar as string
Dim strprog as string
Dim AdvBinCnt as integer
strvar = "32"
AdvBinCnt = 1
Select Case strvar And 2 ^ AdvBinCnt
Case 1
strprog = "silent & Case Values is: " & (strvar And 2 ^ AdvBinCnt)
MsgBox(strProg)
Case 2
strprog = "Reboot & Case Values is: " & (strvar And 2 ^ AdvBinCnt)
MsgBox(strProg)
Case 4
strprog = "No Reboot & Case Values is: " & (strvar And 2 ^ AdvBinCnt)
MsgBox(strProg)
End Select
I have just copied and pasted same code from VBScript to VB.net Code Behind.
However I could not figure out How above Select Case Expression ( Select Case strvar And 2 ^ AdvBinCnt) is working.
Would some one Please show some light on how this Case Condition (strvar And 2 ^ AdvBinCnt)is working.
Example: This Expression evalutes as select case "32" And 2^1
Note: the Code is working fine as it is and total programs are working depending on this values returned from select Case. I have to send this to my pm asap. however I did n't know how the condition works.
Would some please expalin how it is working or pleae direct me to a web site where I could get some explanation on similar above condition.
Thanks in Advance for your Help.
Thank you,
Vamsy.
Vamsy Krishna
|
|
|
|
|
2 ^ 1 is 2. Doing 2 ^ x gives you the binary number 1000 where there are x 0's after the 1. So, the AND operator returns true if there are any bits set in common between the two numbers, 2 ^ x allows you to specify that the AND operator returns true only if bit number x is set in strvar.
I suspect that because VB is utter crap, strvar is being magically converted into an int for the purpose of this test.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Actually, it's not the string that get's converted to a number. It's the other way around - the (2 ^ AdvBinCnt) is an integer that gets converted to a string. I have no idea why this code was written this way. It's simple math - you don't need the strings.
The expression (strvar And 2 ^ AdvBinCnt), where strvar is "32", won't return the value 32 until AdvBinCnt is 5.
|
|
|
|
|
Ah - well, that's even worse, it ends up being a string comparison. See why I hate VB ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I hate the implied stuff too. I always turn on all of the Strict stuff to eliminate most of it.
OT: I'm not going to make it to the MVP Summit. My wife will be 8 months pregnant by then!
|
|
|
|
|
Hi All
I am using a WebBrowser control to navigate to sites in my VB.Net application. After navigating I want to Navigate to some of the links in it depending on some conditions. Can anybody advise how can I collect the links contained in the WebBrowser Document and how can I Raise a click event for a collected link so that it automatically navigates to the link.
I have written the code as bellow :
Dim link1 As mshtml.HTMLLinkElement
link1 = WebBrowser1.Document.Links(10)
Now How can I click the link link1 to navigate to the link.
Please Help. Thanks in advance.
Sekhar
|
|
|
|
|
Did you try using WebBrowser1.Navigate ?
"Legacy code" often differs from its suggested alternative by actually working and scaling.
—Bjarne Stroustrup
|
|
|
|
|
Hi Nilesh
I had already used that before I get this problem. I am able to navigate to url addresses using
WebBrowser1.Url = New System.Uri(txtURL.Text)
and after navigating to the site in the txtURL i found there are several links and several buttons. I want to know how I can click on a link or a button on the page so that I can actually simulate the process of someone sitting and clicking on the links.
Thanks for your response.
If anybody can help me out in finding a solution to this problem then it will help me a lot.
Thanks in advance.
Sekhar
|
|
|
|
|
Hi All
I am using a WebBrowser control to navigate to sites in my VB.Net application. After navigating I want to Navigate to some of the links in it depending on some conditions. Can anybody advise how can I collect the links contained in the WebBrowser Document and how can I Raise a click event for a collected link so that it automatically navigates to the link.
I have written the code as bellow :
Dim link1 As mshtml.HTMLLinkElement
link1 = WebBrowser1.Document.Links(10)
Now How can I click the link link1 to navigate to the link.
Please Help. Thanks in advance.
|
|
|
|
|
Hi,
On the Webrowser's click event try
link1.Navigate(URLstring).
Hope this helps.
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Thanks Adams for your response.
My problem is when I assign the link in the line
link1 = WebBrowser1.Document.link(10)
it doesn't produce any output and the immediate line after this line also doen't gets executed. I think some errors occur in this line and the compiler is not able to track it. for which the focus goes to the exe after this line gets executed. If you can help me out in solving the problem, it will be a great help.
Thanks in advance.
Sekhar
|
|
|
|
|
Hi All,
I have Process ID(PID).
Consider, Iam opening Word Document(a1.doc), It has a PID called 2010.
Then, when i open another file (b1.doc) using the same window again, it shows same pid for both.
How can i get differentiate both the files using the PID?.
Thanks & Regards
Kumaran
|
|
|
|
|
You can't. They're using the same process. A single instance of Word can open multiple documents at the same time, so there's only going to be one process ID.
|
|
|
|
|
I am new to the code project. Can anybody help me in the code for making our application to run before explorer.exe (in Windows XP)? I didn't mean a startup edit..
Please reply..
Help mee
|
|
|
|
|
The only thing that runs before windows starts is the gina.dll, AFAIK.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Help!
Does anyone have a simple (and I mean simple) example of VB calling a C++ DLL with a floating point array parameter where C++ will modify the contents of the parameter? (I'd say "pass by reference" but this is ambiguous when discussing a call from VB.)
I've done this with strings and although it's a little finicky, it definitely works. The online examples either don't compile for truly insidious reasons (thank you MS), or are down level and don't understand SAFEARRAYS etc.
To be clear (hopefully), The idea is: VB program w/array of floating point calls C++ (or C) program that modifies the array. On return to VB, the array is modified.
Thanks.
|
|
|
|
|
I am accessing an oracle table and displaying the table in a datagrid. I am able to add rows to the table and update the database, send queries to the table and retrieve the data and display it in the datagrid. I can not figure out how to delete rows from the datagrid
I want to be able to select a row on the datagrid and click Delete and "poof" the row is gone. In a seperate procedure I will be updating the database table.
I have tried many different ways with no success.
Any one have an idea that would help?
Erica
|
|
|
|
|
Set the rowstate of the offending row to deleted
use a dataview to populated the datagrid
set the dataview filter on the rowstate
|
|
|
|
|
I get an error >
Line 1: Incorrect syntax near 'Username'
When i run the code below
hdstr = "SELECT Password FROM LogIn WHERE Username='" & UsernameTextBox.Text & "'"
hdcmd = New SqlCommand(hdstr, hdcon)
hdcmd.Parameters.Add(New SqlParameter("Username", UsernameTextBox.Text))
Dim usr As String = hdcmd.ExecuteScalar()
Please help.
JESA
|
|
|
|
|
hdstr = "SELECT Password FROM LogIn WHERE Username= @UserName"
hdcmd = New SqlCommand(hdstr, hdcon)
hdcmd.Parameters.Add(New SqlParameter("@Username", UsernameTextBox.Text))
Dim usr As String = hdcmd.ExecuteScalar()
|
|
|
|
|
Thank You.
It worked.
JESA
|
|
|
|
|
I'm having problems understanding why a loop is needed to read from a deflated stream. i've replaced the read all bytes in stream method with the following line, however the data in the output buffer is 1 byte smaller than it was before the data was compressed:
Return stream.Read(buffer, 0, buffer.Length)
used to be:
Dim offset As Integer = 0<br />
Dim totalCount As Integer = 0<br />
While True<br />
Dim bytesRead As Integer = stream.Read(buffer, offset, 100)<br />
If bytesRead = 0 Then<br />
Exit While<br />
End If<br />
offset += bytesRead<br />
totalCount += bytesRead<br />
End While<br />
Return totalCount
the full code for this is taken from http://msdn2.microsoft.com/en-us/library/system.io.compression.deflatestream(VS.80).aspx[^]
|
|
|
|
|
The Read method doesn't have to read all data that you request. It returns the number of bytes actually read, so you have to loop until you have filled the buffer or until the method returns zero.
Dim offset As Integer = 0
Dim bytesRead As Integer
Do
bytesRead = stream.Read(buffer, offset, buffer.Length - offset)
offset += bytesRead
Loop Until bytesRead = 0 Or offset = buffer.Length
Return offset
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Hi
This is Rajesh. I developed a vb 6.0 application. In that i want to access my database server table via web service in vb.net 2005.
I tried some methods for last two weeks.Please someone assist me
Thank you
c.Rajesh B.E
|
|
|
|