Visual Basic Expert


Closed Thread
Results 1 to 5 of 5
  1. #1

    Default Visual Basic Expert

    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.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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
    Code:
    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!
    Last edited by mister_e; - 13th November 2005 at 19:31.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    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.

  4. #4
    tdavis80's Avatar
    tdavis80 Guest


    Did you find this post helpful? Yes | No

    Talking

    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)

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Hi TDavis80,
    Thank you I will try now your code ,
    Thanks a lot.
    Regard Pesti

Similar Threads

  1. Sending Commands from Visual Basic about IR to Pic
    By tne_de in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th April 2009, 06:09
  2. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. Visual Basic 2005
    By keithdoxey in forum Off Topic
    Replies: 4
    Last Post: - 1st August 2007, 12:10
  4. PIC to serial with visual basic
    By mbw123 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 31st March 2007, 16:06
  5. Visual Basic 6 and Pic com
    By shawn in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th September 2005, 05:21

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts