Overload Resolution.

Ryan`

New member
Joined
Sep 11, 2006
Messages
1
Programming Experience
1-3
I've recently converted a project from vb into vb.net; as i'm not familiar with vb. once compiled i recieve a handfull of errors all of which are associated with the same lines of code.

VB.NET:
start = InStr(start, data, "Set-Cookie: ") + 12
the above line of code is perfectly acceptable within the Visual Basic 6.0 environment, however, within Visual Studios the line is flawed as a result of

"Set-Cookie: "

VB.NET:
start = InStr(start, data) + 12
the above code gives no errors; however, the applcation wont function?

overload resolution failed because no accessible 'InStr' can be called without a narrowing conversion.
 
That code is a load of rubbish I'm afraid. The first argument is supposed to be a string, so that implies that 'start' is a String. The InStr function returns an integer, which you then add 12 to and assign the result to 'start', which we've already esdtablished is supposed to be a String, not an Integer. Finally, the third argument is supposed to be a CompareMethod. "Set-Cookie: " is not a CompareMethod. All you have to do is let Intellisense guide you. Microsoft spent millions of dollars developing this advanced IDE that is just begging to help you and it gets ignored. Simply type "instr(" in the IDE and Intellisense will pop up and describe the method and each argument. It will even show you the valid values for the third argument, once you've entered the other two, and you can select a value with a mouse click ot the keyboard.

Having said all this, in .NET you should use the String.IndexOf method anyway.
 
Why dont you tell us what youre trying to achieve.. it looks like youre pulling apart the headers of an HTTP request or response?

I'm *sure* MS will have made some VB.net class you can upgrade to that just gives you them as a collection

Press F2 and type HTTP.. you can see things like

HttpResponseHeader
HttpWebRequest

in the results. Perhaps one of those can satisfy your needs. FInd a tutorial on how to use it.. ?
 
Back
Top