[RESOLVED] [Help]instr returning Wrong value?
Im having a problem with instr Its simply put, returning an unexpected value. I search for the position of 2 characters "(" and ")".
String Im using instr on
Code:
INSERT INTO Drop_Data (dropperid, itemid, minimum_quantity, maximum_quantity, questid, chance) VALUES
now the "(" returns the correct position of 23.
However when instr looks for ")" it finds it incorrectly at position 94
Code:
If fline = 1 Then
TextOutPut(0) = ttext & vbCrLf
a = InStr(1, TextOutPut(0), "(")
b = InStr(1, TextOutPut(0), ")")
Debug.Print ttext
ttext = Mid(TextOutPut(0), a, b)
Debug.Print ttext
End If
thats the code im using right now I need ttext to be equal to the data inside the "(" and ")". Anyone got any ideas why instr isnt working?
Re: [Help]instr returning Wrong value?
I wouldn't be so sure about Instr not working properly, what I would be concerned about is the parameters you are passing to Mid:
Code:
ttext = Mid(TextOutPut(0), a, b)
The third parameter is not the end position, it is the amount of characters from the start position.
For example: If a contained 2 and b contained 3, you would get 3 characters starting at character 2 (so the 2nd, 3rd, and 4th characters).
Re: [Help]instr returning Wrong value?
in other words, instr is returning the correct position. ) is at the 93rd position in the original string... if you want to get it relative to the start position, you need to take that into account
Code:
ttext = Mid(TextOutPut(0), a, b-a)
-tg
Re: [Help]instr returning Wrong value?
Whoops Lol Thanks. Normally I only read 1 letter with mid so I wasnt thinking