[RESOLVED] what is wrong with this? Not checking at all?
I dont know why it doesnt check it.... I want it to stop the user from putting the same text in twice. It does it at first, but when u restart the program, it doesnt... Why is that? I attached the project bellow. Please take a look at it.
Doing some debugging and stepping through the code, while checking contents of variables will probably give you the answer. Here's a very good debugging tutorial by Marty http://www.vbforums.com/showthread.php?t=516261
EDIT: I dont have VB6 now so I'm viewing the code in notepad, here's a tip about this block of code
Code:
Dim qua
For qua = 1 To i
If "74.125.87.103 " & Trim(Text1.Text) = filetext(i) Then
txtthere = True
Else
End If
Next qua
Declare variable types. If you leave "Dim qua" VB will use Variant. So always declare type like "Dim qua As Long"
Also, you have an empty Else statement. Instead of else do an Exit For, because once a duplicate is found there is no need to check the other items in the list. It's more efficient to just exit.
Last edited by baja_yu; Jun 20th, 2010 at 03:22 PM.
Re: [RESOLVED] what is wrong with this? Not checking at all?
You're welcome!
I have one more recommendation for you that will make your life a lot easier, especially when working with larger projects. Take up and use a naming convention for variables and controls. Adding prefixes like txt to text boxes, lbl to Lables, lst to Listboxes etc. So you have something like:
txtUsername
lblTitle
lstItems
Same goes for variables, you can use one letter prefixes, but I like to use three, for example
Dim lngI As Long
Dim strUsername As String
The point of this is that then you know the control or variable type just by looking at the name, and you don't have to check the declaration. So when you see "bolFound" in the code, you immediately know that it's a Boolean type variable.
It makes debugging a lot easier. For example if this line of code was giving you a Type mismatch error:
users = "something"
(assuming 'users' an Integer) You need to poke around to figure out why, but if you declared with a prefix you would have
intUsers = "something"
and will instantly know that the problem is that you are trying to assign a string value to an integer variable.