PDA

View Full Version : Visual Basic Expert



Pesticida
- 13th November 2005, 15:28
Hi,
Did some one know how can I read this data from visual basic:

PICCONTROLLER:
ADCIN 0, A0
ADCIN 1, A1
ADCIN 2, A2
ADCIN 3, A3
ADCIN 4, A4
ADCIN 5, A5
ADCIN 6, A6
ADCIN 7, A7
ADCIN 8, A8


pause 50

hserout ["A",#A0 ,"B",#A1 ,"C",#A2 ,"D",#A3,"E","1",13,10] ' send it


I want that my program read this data and when I have "A" then put #A to string ML1,when I have "B" then put #B to ML2 and so on.
I need the right routine to do that.

Thanks.

Regard pesti.

mister_e
- 13th November 2005, 19:20
you'll have to parse the string on the PC side. look for instr MID$, LEFT$ well at least those VB command.

Also The Bruce Website may give you some pointers...
http://www.rentron.com/parsingstrings.htm

Say thanks to Bruce to provide such great free stuff :)

Personnaly i never send preamble, just send all value to PC then parse the string. USE DEC3 for byte, DEC5 for word ensure to have a fix string format


a var byte
b var byte
c var word
a=10
b=100
c=12345

hserout [dec3 a, dec3 b, dec5 c]

this will send 01010012345 in a fix string format (length). Easy huh!

Pesticida
- 13th November 2005, 20:55
Hi,
Thank you for the answer ,Yes I know the Rentron page ,but I have the problem with the output from my ADCIN conversion,
sometimes is greater as 99 and sometimes smaller as 100 then I have 2 or three digit.
But I can now test with your example, I need like in your example a fix string lenght.
My problem was that I can not stop after the string ex. "A" the next 3 digits.

Regard Pesti.

tdavis80
- 14th November 2005, 04:57
I think you said your string will look like so:

A12B32C112D33

Is that so?

If yes, then here is a way to do it:

dataIN = "A12B32C112D332" ' or however you get data into the PC

start = instr(dataIN, "A") ' find the A
stop = instr(dataIN, "B") ' find the B
A = mid(dataIN, start+1, stop-start-1) ' everything between the A & B is A

start = instr(dataIN, "B")
stop = instr(dataIN, "C")
B = mid(datain, start+1, stop-start-1)

start = instr(dataIN, "C")
stop = instr(dataIN, "D")
C = mid(datain, start+1, stop-start-1)


until the last entry

start = instr(dataIN, "D")
D = mid(dataIN, start+1)

Since D is the last on the string it automatically is everything to the right of D (no Stop= parameter)

Pesticida
- 14th November 2005, 16:58
Hi TDavis80,
Thank you I will try now your code ,
Thanks a lot.
Regard Pesti