|
-
Dec 14th, 2001, 05:42 AM
#1
Thread Starter
Addicted Member
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.
-
Dec 14th, 2001, 05:43 AM
#2
Retired VBF Adm1nistrator
Iterate through to the end of the string and pick each number out using mid()
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Dec 14th, 2001, 05:45 AM
#3
Thread Starter
Addicted Member
-
Dec 14th, 2001, 05:47 AM
#4
Retired VBF Adm1nistrator
yup
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Dec 14th, 2001, 05:47 AM
#5
Junior Member
why dont you use cstr function and the mid function???
mytext= cstr(mynumber)
number1=mid(mytext,1,1)
-
Dec 14th, 2001, 05:49 AM
#6
Thread Starter
Addicted Member
-
Dec 14th, 2001, 05:50 AM
#7
Retired VBF Adm1nistrator
VB Code:
Option Explicit
Private Sub Command1_Click()
On Error Resume Next
Dim i As Long
For i = 1 To Len(Text1.Text)
Debug.Print "Position (" & i + 1 & ") minus position (" & i & ") : " & _
CLng(Mid(Text1.Text, i + 1, 1)) - CLng(Mid(Text1.Text, i, 1))
Next
End Sub
Private Sub Form_Load()
Dim i As Long
Text1.Text = ""
For i = 1 To 9
Text1.Text = Text1.Text & i
Next
End Sub
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Dec 14th, 2001, 05:54 AM
#8
Hyperactive Member
VB Code:
dim intX as integer
dim strResult as string
dim strNumber as string
strNumber = trim$(cstr$(lngTestNumber))
For intX = 1 to len(strNumber)
if strResult <> "" then
strResult = strResult & ", "
end if
strResult = strResult & mid$(strNumber, intX, 1)
Next intX
-
Dec 14th, 2001, 05:55 AM
#9
Thread Starter
Addicted Member
plenderj - do u know that u r GREAT???
-
Dec 14th, 2001, 05:57 AM
#10
Retired VBF Adm1nistrator
Originally posted by Tiovital
plenderj - do u know that u r GREAT???
yes
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Dec 14th, 2001, 07:55 AM
#11
Conquistador
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|