Search Tools Links Login

Filter numbers or characters from sting

Filter a string and return numbers or characters

Original Author: Richard_W


only numbers or only characters and optional the filtered numbers and characters in textbox


Public Function NumberOrNoNumber(StrToCheck As String, Numbers As Boolean, Optional NumericTextTarget As TextBox, Optional TextualTextTarget As TextBox)
'    txtFilter = NumberOrNoNumber(txtStringIncludingNumbers, False, txtNumber, txtNoNumber)
'    txtFilter = NumberOrNoNumber(txtStringIncludingNumbers, True)
Dim Nstr As String 'targetstring for al numbers
Dim Tstr As String 'targetstring for everything exept numbers
Dim i As Integer
  For i = 1 To Len(StrToCheck)
    If IsNumeric(Mid(StrToCheck, i, 1)) Then Nstr = Nstr & Mid(StrToCheck, i, 1) Else Tstr = Tstr & Mid(StrToCheck, i, 1)
If Numbers Then NumberOrNoNumber = Nstr Else NumberOrNoNumber = Tstr
On Error Resume Next
NumericTextTarget = Nstr 'optional target for the numbers filtered out
TextualTextTarget = Tstr 'optional target for the text filtered out
End Function

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 100 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.