![]() |
Need help with VB Function
for some reason I cant get this to work. I need to remove all numbers from the end of a string leaving the ones at the beginning. So for example K1WIST-VED12 would = K1WIST-VED
Code:
Function StripNumber (GetComputerName As String) |
Re: Need help with VB Function
OK. I have corrected the code for you. Here it is :
Code: VB
It should work fine. The code is pretty self-explanatory. But I would just explain one point : in the else condition of the If block inside the loop, you should use "Exit For" so that the control jumps out of the for loop when thefirst non-numeric character (from end) is encountered. |
Re: Need help with VB Function
Thank you for the reply but Im getting a Microsoft VBScript compilation error: Expected end of statement for the As String and As Integer statements when i remove them that error clears but returns blank
|
Re: Need help with VB Function
You should have mentioned that you are using VBScript.
The code I gave would compile fine in VB6. Anyway, here is the VBScript Code: Code: VB
To try the above func, here is a test program: Code: VB
The previous code had a very minor bug which return "blank" only when the input text was *purely* alphabetical. Hope this one is alright. Tell me if it works .. :) |
| All times are GMT +5.5. The time now is 04:27. |