|
-
Mar 25th, 2000, 02:04 AM
#1
Thread Starter
Junior Member
how can i just take some park of a nomber, like a = 12345678 but i just want the begining 4 digit to assign to b or may be the middle 4 digit or the last 4 digit, how?
-
Mar 25th, 2000, 02:13 AM
#2
Lively Member
Hello,
Look up the following in the VB Help files,
Mid,
Left,
Right,
These should help you to extract anything from anywhere from a string.
Desire.
-
Mar 25th, 2000, 02:14 AM
#3
Fanatic Member
I think you could probably turn the number into a string, then use some string manipulation functions, then turn is back into a number.
Eg :
' number into string
strNumber = cstr(12345)
' get first 3 digits
strFirst3Digits = Left$(strNumber, 3)
' string into number
intNumber = cint(strFirst3Digits)
Hope this helps. 
-
Mar 25th, 2000, 02:22 AM
#4
Frenzied Member
another option would be
12345678 \ 10000 'integer division
and
12345678 mod 10000
-
Mar 25th, 2000, 03:34 AM
#5
transcendental analytic
I have a function for it:
-------------------------------Code
Function numdigit(num, startdigit, lendigit)
If Not IsNumeric(num) Then Exit Function
If (startdigit + lendigit) > Len("" & num) Then Exit Function
numdigit = Val(Mid("" & num, startdigit, lendigit))
End Function
-------------------------------
To use it:
-------------------------------Code
Debug.Print numdigit(12345678, 2, 4)
'shoud show "2345"
-------------------------------
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
|