I see it everywhere, people with blogs posting up ASP.NET/VB.NET code snippets. At work I'm always asked to create a quick function how to do something. Or someone will say, "how do I do this?" and I can't help myself but write out the code real quick. So I thought why not me? Why don't I start putting up my own code on my own blog? So here I am.
So my first piece of code is super simple, just strips out numeric characters from an alpha-numeric string. Now maybe there's already a built-in method in .Net that does this already, but .Net is so full of methods and namespaces and such that I don't know them all.
So here we begin a new blog theme.
1: ''' <summary>
2: ''' Strips out Numeric characters from a Alpha-Numeric String
3: ''' </summary>
4: ''' <param name="HotStripper">Send Alpha-Numeric String</param>
5: ''' <returns>String</returns>
6: Function StringOutNumbers(ByVal HotStripper As String) As String
7: Dim NewValue As String = ""
8: For I As Integer = 0 To HotStripper.Length - 1
9: If IsNumeric(HotStripper.Substring(I, 1)) = False Then
10: NewValue += HotStripper.Substring(I, 1)
11: End If
13: Return NewValue
14: End Function
Dim myString As String = StringOutNumbers("Something1234")
Note: If you wanted only to pull out the numbers you could just change line 9, from False to True.