Ad blocker detected: Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker on our website.
CLS
Temp$ = "Mid$ is|a better solution."
Sep% = INSTR(Temp$, "|")
ans$ = MID$(Temp$, 1, Sep% - 1)
que$ = MID$(Temp$, Sep% + 1)
PRINT Sep% 'not really need; for debugging only
PRINT ans$ 'not really need; for debugging only
PRINT que$ 'not really need; for debugging only
PRINT
PRINT "All finished!"
Output:
8
Mid$ is
a better solution.
All finished!
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!
If your first reading is:
"answer|question "
then the INSTR function should return 7, not 9, as "|" is the 7th character in the string "answer|question". So, how about clearing up this discrepancy first?
With 9 as the answer, "r|question" is correct. Could it be that the reading is, actually, " answer|question", that is, "answer|question", with two spaces in front?
I tried your program with "answer|question" as the string, and I got the correct answers, 7, "answer" and "question".
Ralph. Running QuickBASIC Version 4.5, Windows XP Home Edition, Version 2002, Service Pack 2, and HP LaserJet 4L printer.
Try converting all the numeric variables to integer(%) first. I don't have much time right now... Mid$ works correctly for me though.
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!