Results 1 to 5 of 5

Thread: [RESOLVED] what is wrong with this? Not checking at all?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Resolved [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.
    Attached Files Attached Files
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: what is wrong with this? Not checking at all?

    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.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: what is wrong with this? Not checking at all?

    Okay. i found the problem. Thanks! =D
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  4. #4
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    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.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: [RESOLVED] what is wrong with this? Not checking at all?

    Hmm.... Okay. Thanks. =)
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width