|
-
Mar 5th, 2007, 05:08 AM
#1
Thread Starter
Lively Member
get number inside the string
for example:
Sampling Frequency(ms)....50
how to get the '50' inside the string?
the number will always at the behind of the string, but the problem is the number will not always in 2 digit.....may be 3 or 1 digit.....
so right(str,2) cannot be used in this case.....
-
Mar 5th, 2007, 05:15 AM
#2
Re: get number inside the string
-
Mar 5th, 2007, 05:18 AM
#3
Re: get number inside the string
Will there always be the "...."? or will it sometimes be shorter or longer? Also if it changes in length, will it be the only point in the whole string, or might there be one in the name?
-
Mar 5th, 2007, 05:18 AM
#4
Thread Starter
Lively Member
Re: get number inside the string
vb Code:
Private Sub Command1_Click()
Dim a
Dim b
a = "Sampling Frequency(ms)....50"
b = CStr(a)
Label1.Caption = b
End Sub
the answer is not 50....
-
Mar 5th, 2007, 05:19 AM
#5
Thread Starter
Lively Member
Re: get number inside the string
the '...........' is fix......just the number will change
-
Mar 5th, 2007, 05:21 AM
#6
Re: get number inside the string
Code:
Private Sub Command1_Click()
Dim lPos As Long, lNum As Long, sString As String
sString = "Sampling Frequency(ms)....50"
lPos = InStrRev(sString, ".")
If lPos Then lNum = CLng(Mid$(sString, lPos + 1) & ".0")
MsgBox lNum
End Sub
-
Mar 5th, 2007, 05:24 AM
#7
Thread Starter
Lively Member
Re: get number inside the string
type mismatch......... :'-(
-
Mar 5th, 2007, 05:25 AM
#8
Re: get number inside the string
 Originally Posted by chxxangie
type mismatch......... :'-(
i forgot a +1 which I've since added to the code above.
-
Mar 5th, 2007, 05:26 AM
#9
Thread Starter
Lively Member
Re: get number inside the string
yeah, it works......thank you so much......
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
|