Results 1 to 3 of 3

Thread: Quick n Dirty question on Strings

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Posts
    25

    Wink

    Man.. am I ever asking annoying questions

    What is the method of getting at the 1st element in a string? Kinda figured out that str(0) won't quite do the job for me. And don't have my reference book handy. Anyone mind giving me the quick n dirty chunk of code I need to do this, thanks

    If you are wondering, I am firing in a huge chunk of data in my serial port, which I have a header byte telling the app whats in the rest of the chunk is. Do particular cases send appropriate stuff to turn devices on and off, and so forth.

    Just need to know how I get at that first subscript

    Mark Wight
    x86 ASM, AS11 ASM, C, C++, Java.

  2. #2
    Member
    Join Date
    Oct 2000
    Posts
    50
    Hi,

    I guess left(myString,1) won't do the trick... or? Otherwise try to spilt the string!

    Code:
    theString = "Try to split"
    myString = Split(theString, " ")
    result = myString(0)
    The result-variable will now hold "Try".

  3. #3
    Guest
    Or use InStr.
    Code:
    TheString = "Try to split"
    MsgBox Left(TheString, InStr(1, TheString, " ") - 1)

Posting Permissions

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



Click Here to Expand Forum to Full Width