PDA

Click to See Complete Forum and Search --> : Can anyone help me with strings?


ravcam
Jan 8th, 2000, 04:27 AM
Here is the question!

ok if txtinput.text = 2+(4/(2*6))
would this statement return that the value of strtemp = (4/(2*6))

strCalc = txtInput.Text
intCurpos = InStr(intCurpos, "(", strCalc, vbTextCompare)
Do
intTempLastPar = intLastPar
intLastPar = InStr(intLastPar, ")", strCalc, vbTextCompare)
Loop Until InStr(intLastPar, ")", strCalc, vbTextCompare) = 0
strTemp = strCalc - Left$(strCalc, intCurpos - 1) - Right$(strCalc, intLastPar + 1)
MsgBox strTemp



[This message has been edited by ravcam (edited 01-08-2000).]

Bob Baddeley
Jan 8th, 2000, 05:09 AM
Make a textbox and say texttest.text = strtemp. then you'll know.

ravcam
Jan 8th, 2000, 05:11 AM
I did but I keep getting compiler errors! In my code and don't know what is wrong!

Clunietp
Jan 8th, 2000, 05:34 AM
if intCurpos = 0 then you will get an error in the InStr function

ravcam
Jan 8th, 2000, 07:31 AM
Thank you Clunietp but that was not my problem but. I did find a way to to do it if anyone wants to compare this code to that above!

strCalc = txtInput.Text
intCurpos = InStr(intCurpos, strCalc, "(", vbTextCompare)
Do
intTempPar = intPar
intPar = InStr(intPar + 1, strCalc, ")", vbTextCompare)
Loop Until intPar = 0
strTemp = Mid(strCalc, intCurpos, intTempPar - intCurpos + 1)