Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mid problem

Status
Not open for further replies.

JavaDude32

Programmer
Aug 25, 2001
180
US
I have a loop that essentially breaks down a string character by character (if there is a charAt or any type of method such like please point me to it). It refuses a variable as a 2nd argument even with the CLng conversion function.

Dim intTemp
For I = 0 to Len(Session("mapFeatures"))-1 Step 1
intTemp = Session("mapFeatures")
intTemp = Mid(intTemp,CLng(I),1)
intTemp = CInt(intTemp)
mapFeatures(intTemp) = "yes"
Next

 
[tt]InStr(string1, string2)[/tt] is the analagous function in VB. It returns a long value, either the position of string2 in string1, a zero if not found, or null if string1 is a zero-length string.

There is also the InStrRev function, which works in much the same way, only going from right to left.

HTH,
jp
 
Is it giving you an error? if so at which line?

One thing i see is that your writing over the previous
value with each "mid"

do you want: intTemp=inTemp & Mid(inTemp,CLng(I),1) ?


 
It won't look in the right spot, what I want to do is see what character is in the 3rd slot in the string, sorta like a C++ char array since I'm using this to store array slot values.
 
First
intTemp = Mid(intTemp,CLng(I),1)
fails for I=0 since Mid starts at 1

Dim intTemp
dim sTemp
sTemp = Session("mapFeatures")
For I = 1 to Len(sTemp) Step 1
intTemp = Mid(sTemp,I,1)
'''??? Where us the mapfeatures Array defined
mapFeatures(intTemp) = "yes"
Next




Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Thanks a lot, darn the differences in programming languages argh. I'm too used to java\C++.
 
VB.Net will be more to your liking then.
Use "pure" .NET framework methods like
For I = 0 To sTemp.length - 1
If stemp.Substring(I,1)
Next

or stay VB

For I = 1 To Len(stemp)
If Mid(stemp,I,1)
Next



Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top