Results 1 to 8 of 8

Thread: [RESOLVED] on KeyPress error

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    Resolved [RESOLVED] on KeyPress error

    Hi all,

    Just a quick problem -
    I have a program that has a text box take focus when the program loads. I want it to display some text, which dissapears if you click / get focus in the box. Kinda like a lable. I also DON'T want it to make the label text dissapear when the program loads. I accheived this with the following code:


    Code:
    ' Global declare thingy
    Dim AA as Boolean
    
    ' More code
    
    Private Sub MD51in_GotFocus()
    If AA = False Then
        AA = True
        Exit Sub
    End If
    
    If MD51in.Text = "Actual MD5 Checksum" Then
        MD51in.Text = ""
        MD51in.SetFocus
    End If
    End Sub
    
    Private Sub MD51in_LostFocus()
    If MD51in.Text = "" Then
        MD51in.Text = "Actual MD5 Checksum"
    End If
    End Sub
    
    Private Sub MD52in_GotFocus()
    If MD52in.Text = "Supposed MD5 Checksum" Then
        MD52in.Text = ""
        MD52in.SetFocus
    End If
    End Sub
    
    Private Sub MD52in_LostFocus()
    If MD52in.Text = "" Then
        MD52in.Text = "Supposed MD5 Checksum"
    End If
    End Sub
    However, I have noticed that if you start typing in that box right away, the "lable text" will remain. I tried countering this using an _change()..

    Code:
    Private Sub MD51in_Change()
    If MD51in.Text = "Actual MD5 Checksum" Then
        MD51in.Text = ""
        MD51in.SetFocus
    End If
    End Sub
    But it didn't work. The best solution I can think of is to use _KeyPress or _KeyDown:

    Code:
    Private Sub MD51in_KeyPress()
    If MD51in.Text = "Actual MD5 Checksum" Then
        MD51in.Text = ""
        MD51in.SetFocus
    End If
    End Sub
    But if I try that, it gives the following error:



    Any ideas?

  2. #2
    Lively Member
    Join Date
    Aug 2005
    Posts
    77

    Re: on KeyPress error

    You need this in your function:
    VB Code:
    1. Private Sub MD51in_KeyPress([B]KeyAscii As Integer[/B])
    Pieter

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    Re: on KeyPress error

    Perfect! Thanks ^__^

    Just another quick Q - Is there a maximum character limit that all MD5 checksums are, or are they all different?

  4. #4

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    Re: on KeyPress error

    65k? Kilobytes? I mean the actual key. thing. For example, the Checksum for Notepad.exe is
    388b8fbc36a8558587afc90fb23a3b99

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    Re: on KeyPress error

    And this is the hash of a very large file, over 3 gigs:
    897685ed1eef183514a3dafcb75115e9

    They are all 32 characters - that wouldn't be the limit, would it? Or does it depends on the amounts of files or types of files?

  7. #7
    Hyperactive Member Fedhax's Avatar
    Join Date
    Aug 2006
    Posts
    293

    Re: on KeyPress error

    Quote Originally Posted by Arby
    They are all 32 characters - that wouldn't be the limit, would it? Or does it depends on the amounts of files or types of files?
    "The 128-bit (16-byte) MD5 hashes (also termed message digests) are typically represented as a sequence of 32 hexadecimal digits."

    (Taken from Wikipedia)

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    Re: on KeyPress error

    Ah, so they are always expressed in 32 characters? I'll put that as the max length then XD.

    Thanks!

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