|
-
Jul 18th, 2005, 02:33 PM
#1
Thread Starter
Addicted Member
Filter Textbox?
i have a multilined textbox filled with about 10 digit numbers in a list
how would i filter so that it will only show the numbers that start with say 94.65
cheers william
Nothing is Impossible you say?......Try slamming a revolving door!
-
Jul 18th, 2005, 02:36 PM
#2
Thread Starter
Addicted Member
Re: Filter Textbox?
forgot to mention id like to have a few filters e.g
94.65
80.65
96.26
remember there are another 6 digits after they numbers which are pretty random.
Nothing is Impossible you say?......Try slamming a revolving door!
-
Jul 18th, 2005, 02:44 PM
#3
Re: Filter Textbox?
VB Code:
Private Sub Command1_Click()
Dim MyArr() As String
Dim i As Integer, StrBuff As String
ReDim Preserve MyArr(4)
MyArr(1) = "10"
MyArr(2) = "153"
MyArr(3) = "162"
MyArr(4) = "142"
For i = 1 To 4
StrBuff = StrBuff & Mid(Text1.Text, i, 1)
Next
For i = 0 To UBound(MyArr)
If MyArr(i) = StrBuff Then MsgBox MyArr(i)
Next i
End Sub
It will filter good
-
Jul 18th, 2005, 02:51 PM
#4
Thread Starter
Addicted Member
Re: Filter Textbox?
Thanks a bunch ill try it as soon as i get home
Nothing is Impossible you say?......Try slamming a revolving door!
-
Jul 18th, 2005, 03:55 PM
#5
Thread Starter
Addicted Member
Re: Filter Textbox?
do i click that command button before or after i have numbers in the text box :S
Nothing is Impossible you say?......Try slamming a revolving door!
-
Jul 18th, 2005, 04:19 PM
#6
Re: Filter Textbox?
After, but I have my doubts that this is what you wanted. Try it and post back.
-
Jul 18th, 2005, 04:34 PM
#7
Thread Starter
Addicted Member
Re: Filter Textbox?
not working :/
anyone else got any ideas?
Nothing is Impossible you say?......Try slamming a revolving door!
-
Jul 18th, 2005, 04:56 PM
#8
Re: Filter Textbox?
Not clear where you're getting the filter, but this will do what you need.
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim arr() As String
Dim x As Integer
Dim str As String
Dim test As String
arr() = Split(Text1.Text, vbCrLf)
For x = 0 To UBound(arr)
test = Left(Format(Val(arr(x)), "##.###"), 5)
If Text2.Text = test Then
str = Text2.Text & vbCrLf
End If
Next x
MsgBox str
End Sub
Private Sub Form_Load()
Text1.Text = "94.1253454345" & vbCrLf & "94.55534534" & vbCrLf & _
"96.234345345" & vbCrLf & "66.252345345" & vbCrLf & "33.555345345"
Text2.Text = ""
End Sub
Just type your filter into text2, and press the button. All matching records will be in a msgbox.
Last edited by dglienna; Jul 18th, 2005 at 07:10 PM.
-
Jul 19th, 2005, 06:09 AM
#9
Thread Starter
Addicted Member
Re: Filter Textbox?
Thats looking good so far but in the msgbox its only show what i typed, as in i still need the last 6 digits to show, so something like that but when i type in 33.55 id like the msgboz to say 33.555345345 instead of just 33.55
Thanks for the time
Nothing is Impossible you say?......Try slamming a revolving door!
-
Jul 19th, 2005, 09:33 AM
#10
Re: Filter Textbox?
sorry dg......i tried this just to check what exactly u wanted this code to do but i m getting empty msgbox.....
-
Jul 19th, 2005, 01:20 PM
#11
Re: Filter Textbox?
Hey, glad I didn't destroy them.
Just change the output variable.
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim arr() As String
Dim x As Integer
Dim str As String
Dim test As String
arr() = Split(Text1.Text, vbCrLf)
For x = 0 To UBound(arr)
test = Left(Format(Val(arr(x)), "##.###"), 5)
If Text2.Text = test Then
str = str & arr(x) & vbCrLf ' <--------------- This line changed
End If
Next x
MsgBox str
End Sub
Private Sub Form_Load()
Text1.Text = "94.1253454345" & vbCrLf & "94.55534534" & vbCrLf & _
"96.234345345" & vbCrLf & "66.252345345" & vbCrLf & "33.555345345"
Text2.Text = ""
End Sub
-
Jul 19th, 2005, 04:18 PM
#12
Thread Starter
Addicted Member
Re: Filter Textbox?
yeah man im getting an empty msgbox aswell now :/
Nothing is Impossible you say?......Try slamming a revolving door!
-
Jul 19th, 2005, 04:23 PM
#13
Re: Filter Textbox?
I dont get why my code wont work? Mine compares the first 4 numbers with the numbers in MyArr() so i dont see whats wrong there
-
Jul 19th, 2005, 04:27 PM
#14
Thread Starter
Addicted Member
Re: Filter Textbox?
em it just showed me what i typed in :/
But problem solved i just had to tweak the number of digits after the filter
Cheers guys
Nothing is Impossible you say?......Try slamming a revolving door!
-
Jul 19th, 2005, 04:37 PM
#15
Re: Filter Textbox?
Here is a slight change to the routine that helps with variable number of digits
VB Code:
Private Sub Command1_Click()
Dim arr() As String
Dim x As Integer
Dim str As String
Dim test As String
Dim isMatch As Boolean
If Text2 = "" Then
MsgBox "Enter a number in Text Box 2 first"
Exit Sub
End If
arr() = Split(Text1.Text, vbCrLf)
For x = 0 To UBound(arr)
test = Left(arr(x), Len(Text2))
If Text2.Text = test Then
MsgBox "Match: " & arr(x)
isMatch = True
End If
Next x
If Not isMatch Then MsgBox "No Match Found"
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|