Results 1 to 5 of 5

Thread: Seperate Character From String

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482

    Exclamation

    Hi, i have a string of 150 characters
    I need to process each character 1 by 1..
    And *ONLY* the 150 from the string..
    so if there are 151 in the string.. then DON'T process any above 150

    i need to process each character 1 by 1.. so its like
    the character can be A-Z, 1-9, or any character that is like ®©žó.. ETC.

    and i need to see what character it is on so far..
    so if i is on character 15, then some variable will
    = 15..
    that way i can use it in other ways.

    Code:
    dim ProChar as <What ever it needs to>
    prochar = first character
    if prochar= "a" then
    'do stuff'
    end if
    
    prochar = second character
    if prochar= "a" then
    'do stuff'
    end if
    Thanks.. ALOT

  2. #2
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    You need to use arrays and some string manipulation functions to achieve this, here is some code

    Code:
    Dim str as String ' variable holding string of characters
    Dim characters(0 to 149) as String 
    
        '................CODE to fill str variable
    
        For i = 0 To 149
        
            characters(i) = Mid(str, i + 1, 1) ' get next character in string
    
            Debug.Print characters(i) ' print characters
            
        Next i
    Then you would implement it into your code like this

    Code:
    prochar = characters(1)
    if prochar = "a" then
    'do stuff
    end if
    
    prochar = characters(2)
    if prochar = "a" then
    'do stuff
    end if
    
    ' SO ON



    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Originally posted by YoungBuck

    Code:
    prochar = characters(1)
    if prochar = "a" then
    'do stuff
    end if
    
    prochar = characters(2)
    if prochar = "a" then
    'do stuff
    end if
    
    ' SO ON
    It's better to do something like this:
    Code:
    'loop trough all the chars
    For i = LBound(characters) To UBound(characters)
        'get the char
        prochar = character(i)
        'do something with it
        If prochar = "a" Then
            'do something
        End if
    Next
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  4. #4
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    Yeah I was just implementing the use of the array in the code that progeix had provided...........
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482
    Thnanks Guys, I think I can finish my program soon.
    And implement new features.

    Thanks for the quick response..


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