dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Strange problem!

  1. #1
    Join Date
    Oct 2003
    Posts
    29

    Question Strange problem!

    Hi,
    Consider scenario: I have an Integer array of 4 elements. On the other hand I have a string like,

    Dim str As String
    str = 6372

    Now I have to compare 1st element of array with str's 1st character i.e. 6 similary, 2nd element of array with str's 2nd character i.e. 2 and so on. Kindly guide.

    Bye,
    Viki.

  2. #2
    Join Date
    Apr 2002
    Location
    Los Angeles, Ca
    Posts
    238
    Viki ..
    Consider this code. I knocked it up real quick
    Code:
    Option Explicit
    Dim intArray(3) As Integer
    
    Private Sub Command1_Click()
    Dim i As Integer
    Dim strIn As String
         strIn = CInt("6153")
         
    For i = 0 To UBound(intArray)
         
         If Mid$(strIn, i + 1, 1) = intArray(i) Then
              MsgBox "Match"
         Else
              MsgBox "No Match"
         End If
              
    Next i
    End Sub
    
    Private Sub Form_Load()
    Dim i As Integer
         For i = 0 To UBound(intArray)
              intArray(i) = i
         Next
    End Sub

  3. #3
    Join Date
    Oct 2003
    Posts
    29

    Thumbs up Thanks

    Hi,
    Thank UU. It solved my problem as well as increased my little VB knowledge .

    Bye,
    Viki.
    Last edited by Vikrama Sanjeva; December 27th, 2003 at 02:32 PM.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)