|
-
Feb 27th, 2011, 03:26 AM
#1
Thread Starter
New Member
Datagrid help
hello, this is what i am trying to do:
if textbox1.text = **** then
MsgBox("Correct serial", MsgBoxStyle.DefaultButton1)
form2.show
me.close
else
MsgBox("Incorrect serial", MsgBoxStyle.DefaultButton1)
For the **** part i wish to do this.
if the text in textbox1 one is equal to ANY cell in the column named serial# in datagridview1.
Thanks in advanced.
-
Feb 27th, 2011, 06:05 AM
#2
Re: Datagrid help
There are a few different ways to do this, but let's stick to the basics to begin with. When you want to do the same thing multiple times with different data, your first thought should be a loop. If you say out loud what you want to do, that will pretty much tell you what type of loop to use. In this case, you want to compare the contents of a TextBox with the contents of the cell in a particular column for each row. Obviously, you want to use a For Each loop that loops through the Rows of the grid. Inside the loop, get the Value for the appropriate cell and compare that to the Text of the TextBox.
As for the messages, I'd suggest that you use a Boolean flag to indicate whether a match was found or not. Initialise it to False and, if a match is found in the loop, set the flag to True and exit. At the end of the loop, test that flag and display the appropriate message.
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
|