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.....
Re: get number inside the string
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?
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....
Re: get number inside the string
the '...........' is fix......just the number will change
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
Re: get number inside the string
type mismatch......... :'-(
Re: get number inside the string
Quote:
Originally Posted by chxxangie
type mismatch......... :'-(
i forgot a +1 which I've since added to the code above.
Re: get number inside the string
yeah, it works......thank you so much......