Results 1 to 3 of 3

Thread: How to read characters from string variable

  1. #1
    Guest
    Hi there, I would need to know if there's a way to read characters of any given string variable with vbscript. In my case all I need to find out is the first character of a string. This is how I picture the codes:

    strvar = "A1"
    firstchar = strvar(0)


    ... but I know if I do this I would then make reference to an array which isn't what I wanna do. If you have a better way to do it please let me know. Thanks.

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    Are the Left$, Mid$ and Right$ functions available in VBScript? (I've never done any VBScript)

    If so, then firstchar = Left$(strvar, 1) will do it.

  3. #3
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Actually they are but without the $


    In VBScript, everything is a variant so you have to use the Left(), Right() and Mid() functions instead.

    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

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