Results 1 to 16 of 16

Thread: Default command button

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253

    Question

    I have made my cmdRun button a default button. My question is how can I get my textbox to capitalize once I press enter to run the program. I have a lost_focus routine and in my cmdRun sub I have the txtCubeCupName ucasing and trimming plus I have it so it setfocus. Does anyone have suggestions?

  2. #2
    Lively Member
    Join Date
    Aug 2000
    Posts
    114

    command button

    Make sure you have your command button default property set to true and then in the cmdRun_click sub you want a statement like
    txtCubeCupName.text = Trim$(UCase$(txtCubeCupName.text))

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    I did that and it didn't work. Thank you for your help though. Any other suggestions?

  4. #4
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217
    or how about after making cmdrun default use this
    var = len(txtcubecupname)
    sng1 = left(txtcubecupname,1)
    sng2 = middle(txtcubecpname,2,var)
    txtcubecupname = var
    simpler code, though a bit longer
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  5. #5
    Lively Member
    Join Date
    Aug 2000
    Posts
    114
    Maybe I don't get your question but it works fine for me. What version of VB are you using?

  6. #6
    Lively Member
    Join Date
    Aug 2000
    Posts
    114
    Chris_SE

    Why are you populating the text box the the len of what the text box was before?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    I'm using Visual Basic 6.0

  8. #8
    Lively Member
    Join Date
    Aug 2000
    Posts
    114
    Can you post your code?

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253

    posting code

    This is in my cmdRun sub:

    If UCase(Trim(txtCubeCupName)) = "" Then
    MsgBox "The Cube Cup Name must be entered."
    txtCubeCupName.SetFocus
    Exit Sub
    End If

    And then I have a Lost_Focus event:

    Private Sub txtCubeCupName_LostFocus()
    txtCubeCupName = UCase(Trim(txtCubeCupName))
    End Sub

  10. #10
    Lively Member
    Join Date
    Aug 2000
    Posts
    114
    In your cmdRun_click add the this line - cmdrun.setfocus. Look at the code below.....


    Private Sub cmdRun_Click()
    If UCase(Trim(txtCubeCupName)) = "" Then
    MsgBox "The Cube Cup Name must be entered."
    txtCubeCupName.SetFocus
    Exit Sub
    End If
    cmdRun.SetFocus

    End Sub
    Private Sub txtCubeCupName_LostFocus()
    txtCubeCupName = UCase(Trim(txtCubeCupName))
    End Sub

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    It still doesn't capitalize the data in the txtcubecupname.
    But thanks for your help. Is this even possible?

  12. #12
    Lively Member
    Join Date
    Aug 2000
    Posts
    114
    I am using the same code as you and when I press enter it capatilizes the text box like it is suppose to. Go in debug mode and make sure that your code is executing the cmdRun_click when you hit the enter button. If it doesn't then you must not have the cmdRun set to default

  13. #13
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    put this in the keypress of the textbox in question:
    Code:
    'vb6
    'capitalize all small case letters
    '
        If Chr(KeyAscii) >= "a" And Chr(KeyAscii) <= "z" Then
            KeyAscii = KeyAscii - 32
        End If
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  14. #14
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Here's an alternative to HeSaidJoes code that will capitalize all åäöüï characters
    Code:
    KeyAscii=Asc(Ucase(Chr(KeyAscii)))
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    Hey thanks HeSaidJoe that keypress worked. Thanks thedee23 for being patient with me and all your help.

  16. #16
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    Sorry, my code got cut off

    or how about after making cmdrun default use this
    var = len(txtcubecupname)
    sng1 = left(txtcubecupname,1)
    sng2 = middle(txtcubecpname,2,var)
    var = sng1 & sng2
    txtcubecupname = var

    this should be the full thing
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

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