Results 1 to 4 of 4

Thread: reading a string

  1. #1

    Thread Starter
    Hyperactive Member fasi's Avatar
    Join Date
    Nov 2000
    Posts
    474

    reading a string

    Well . I want to read a string character by character . starting from the end ... I did it before .but now i completely forgot how to do it .. can someone post a code that reads a string each character at at time .. and then we cna decrement the pointer to read the preceeding character ..


    Tahnx

  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    for x = len(yourWord) to 0
    msgbox mid(yourWord,x,1)
    next x


    i'm not sure, but it will problably work,

    it's been long since i did some vb!!

    with what reeset just say,

    if my code does not work, this will

    for x = 0 to len(yourWord)
    msgbox mid(strReverse(yourWord),x,1)
    next x
    Last edited by sebs; Jun 27th, 2001 at 11:30 AM.

  3. #3
    Hyperactive Member
    Join Date
    May 2000
    Location
    Or
    Posts
    316
    If you are just working with a string, use the strReverse command. This will reverse the string, and allow you to read it from beginning to end.

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim test_string As String
    3.  
    4. test_string = "Hello World"
    5. test_string = StrReverse(test_string)
    6. MsgBox test_string
    7.  
    8. End Sub

    Hope this helps.

  4. #4
    Addicted Member Merlin's Avatar
    Join Date
    Dec 2000
    Location
    Eau Claire, WI
    Posts
    233
    VB Code:
    1. Private Sub Form_Load()
    2.    
    3.     Dim lIndex As Long
    4.     Dim sStringToReadIn As String
    5.    
    6.     sStringToReadIn = "Hello World"
    7.    
    8.     For lIndex = Len(sStringToReadIn) To 1 Step -1
    9.        
    10.         If lIndex = 0 Then
    11.             Exit For
    12.         End If
    13.        
    14.         Text1 = Text1 & Mid$(sStringToReadIn, lIndex, 1) & " - " & lIndex & vbCrLf
    15.    
    16.     Next
    17.    
    18. End Sub
    poooof

    Wizard Since 1997
    SQL Server 7.0:2K, Oracle, VB 6.0 EE, VBScript, C/C++, COBOL, RPG ILE, HTML, XML, Perl

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