After 6 weeks of experimenting with PB, after 12 years VB, I decided it was time to bite the bullet and do a live project in PB9 rather than VB.
All the Database stuff works fine but I come unstuck on the most simple bits of code, which in VB I never even had to to think about.
In the code below I read a text field from MSAccess into sComment (code not shown)
I then need to manipulate this string variable and extract two double variables from the manipulated text field.
In the time I've spent on trying to do this, I would probably have completed the complete project in VB or VBA.
Please don't take this as a shot at PB, rather, it's the sheltered life us VB converts come from. So please someone take the 5 seconds it needs to sort me out. Code snip follows. Fails on dLeft=CDBL(LEFT$(sComment,ip-1))
(Not sure about dRight, didn't get that far)
TIA
~~~
#COMPILE EXE
#DIM ALL
FUNCTION PBMAIN () AS LONG
DIM sComment AS STRING
DIM iP AS INTEGER
DIM dLeft AS DOUBLE
DIM dRight AS DOUBLE
sComment = "180 x 100cm"
REPLACE " " WITH "" IN sComment
REPLACE "cm" WITH "" IN sComment
ip=INSTR(sComment,"x")
MSGBOX STR$(ip)
dLeft=CDBL(LEFT$(sComment,ip-1))
MSGBOX STR$(dLeft)
dRight=(CDBL(MID$(sComment,ip+1, LEN(sComment)-ip)
END FUNCTION
All the Database stuff works fine but I come unstuck on the most simple bits of code, which in VB I never even had to to think about.
In the code below I read a text field from MSAccess into sComment (code not shown)
I then need to manipulate this string variable and extract two double variables from the manipulated text field.
In the time I've spent on trying to do this, I would probably have completed the complete project in VB or VBA.
Please don't take this as a shot at PB, rather, it's the sheltered life us VB converts come from. So please someone take the 5 seconds it needs to sort me out. Code snip follows. Fails on dLeft=CDBL(LEFT$(sComment,ip-1))
(Not sure about dRight, didn't get that far)
TIA
~~~
#COMPILE EXE
#DIM ALL
FUNCTION PBMAIN () AS LONG
DIM sComment AS STRING
DIM iP AS INTEGER
DIM dLeft AS DOUBLE
DIM dRight AS DOUBLE
sComment = "180 x 100cm"
REPLACE " " WITH "" IN sComment
REPLACE "cm" WITH "" IN sComment
ip=INSTR(sComment,"x")
MSGBOX STR$(ip)
dLeft=CDBL(LEFT$(sComment,ip-1))
MSGBOX STR$(dLeft)
dRight=(CDBL(MID$(sComment,ip+1, LEN(sComment)-ip)
END FUNCTION
Comment