|
-
Jul 18th, 2004, 07:48 PM
#1
Thread Starter
New Member
text box use to populate array
I want to create an application that:
is a form with a text box and a label
the text box recieves numeric input (values 1-20)
then upon pressing the enter key on the key board
the text in the text box populates a dynamic array, and if the
value is already there the label displays the value that was
entered (the duplicate value).
I know how to set up the GUI but I don't know how to make this work right. Please help as soon as you can. I have a deadline of 6pm Monday July 19th that I have to meet.
any help is appreciated.
-
Jul 18th, 2004, 08:04 PM
#2
Fanatic Member
perhaps
VB Code:
Dim a As New ArrayList()
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
If Not isThere(TextBox1.Text) Then
a.Add(TextBox1.Text)
Else
MessageBox.Show(String.Format("{0} is in the ArrayList", TextBox1.Text))
End If
End If
End Sub
Function isThere(ByVal s As String) As Boolean
Dim o As Object
For Each o In a
If s = o.ToString Then
Return True
End If
Next
Return False
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim o As Object
Dim s As String
For Each o In a
s &= o.ToString & Constants.vbCrLf
Next
MessageBox.Show(s)
End Sub
if not, sorry...
-
Jul 19th, 2004, 04:15 AM
#3
PowerPoster
Hi,
If I understand you, try
VB Code:
Dim arrTest(21) As Boolean ' Form wide scope
Private Sub TextBox1_KeyDown(ByVal sender As Object,
ByVal e As System.Windows.Forms.KeyEventArgs) Handles
TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
If arrtest(cint(TextBox1.Text)) = True then
Label1.Text=TextBox1.Text
Else
Label1.Text=""
End If
arrTest(cint(TextBox1.Text))=True
End If
End Sub
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jul 19th, 2004, 01:26 PM
#4
Thread Starter
New Member
Thanks
Thanks for the quick response I just had to tweak what you gave me a little to make it work and wa la. I'm new to VB and VB.Net as well so I just needed a little guidance that's all.
Thanks again,
tiffjoe
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
|