Results 1 to 11 of 11

Thread: Array or what

  1. #1

    Thread Starter
    Addicted Member Tiovital's Avatar
    Join Date
    Apr 2000
    Posts
    249

    Array or what

    Hi,
    I have to write a program that check a textbox and count the chars (numbers) in it then subtract 2ND number from the 1ST and the 3RD from the 2ND and so on - Now IF the number (after subtract ) is fixed or not. so, how's this done?

    P.S. how can i split a number - 123456789 - to a 1,2,3,4,5,6,7,8,...???

    thanks in advance.

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Iterate through to the end of the string and pick each number out using mid()
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3

    Thread Starter
    Addicted Member Tiovital's Avatar
    Join Date
    Apr 2000
    Posts
    249
    plenderj that was FAST

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    yup
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  5. #5
    Junior Member
    Join Date
    Nov 2001
    Posts
    21
    why dont you use cstr function and the mid function???


    mytext= cstr(mynumber)
    number1=mid(mytext,1,1)


  6. #6

    Thread Starter
    Addicted Member Tiovital's Avatar
    Join Date
    Apr 2000
    Posts
    249
    Hi,
    Ok - then What?

  7. #7
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     On Error Resume Next
    5.     Dim i As Long
    6.     For i = 1 To Len(Text1.Text)
    7.         Debug.Print "Position (" & i + 1 & ") minus position (" & i & ") : " & _
    8.                     CLng(Mid(Text1.Text, i + 1, 1)) - CLng(Mid(Text1.Text, i, 1))
    9.     Next
    10. End Sub
    11.  
    12. Private Sub Form_Load()
    13.     Dim i As Long
    14.     Text1.Text = ""
    15.     For i = 1 To 9
    16.         Text1.Text = Text1.Text & i
    17.     Next
    18. End Sub
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  8. #8
    Hyperactive Member Bananafish's Avatar
    Join Date
    Jan 2001
    Posts
    394
    VB Code:
    1. dim intX as integer
    2. dim strResult as string
    3. dim strNumber as string
    4.  
    5. strNumber = trim$(cstr$(lngTestNumber))
    6. For intX = 1 to len(strNumber)
    7.   if strResult <> "" then
    8.      strResult = strResult & ", "
    9.   end if
    10.   strResult = strResult & mid$(strNumber, intX, 1)
    11. Next intX

  9. #9

    Thread Starter
    Addicted Member Tiovital's Avatar
    Join Date
    Apr 2000
    Posts
    249
    plenderj - do u know that u r GREAT???

  10. #10
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Originally posted by Tiovital
    plenderj - do u know that u r GREAT???

    yes
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  11. #11
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    *cough*b*****cough*

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