lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
I made a spelling mistake in the code below but still working fine.
the currentpostion in the loop
is wrong spelling. I stepped in the code and it is always 0. However, the code worked fine.
Why is that? Thank you
I made a spelling mistake in the code below but still working fine.
the currentpostion in the loop
Rich (BB code):
For x = currentpostion To Len(phrase)
Why is that? Thank you
Rich (BB code):
Sub onlynumber()
Dim phrase As String
Dim lenght As Integer
Dim currentpostion As Integer
Dim temp As String
currentposition = 1
Dim x As Integer
phrase = InputBox("enter string")
For x = currentpostion To Len(phrase)
If (IsNumeric(Mid(phrase, currentposition, 1))) = True Then
temp = temp & Mid(phrase, currentposition, 1)
End If
currentposition = currentposition + 1
Next x
MsgBox (temp)
End Sub