Closed Thread
Results 1 to 2 of 2

$ sign disappears after the exit_Event fires for the first time

Hybrid View

  1. #1
    Registered User
    Join Date
    03-02-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    13

    $ sign disappears after the exit_Event fires for the first time

    Hi,
    I have coded a program to concatenate "$" sign before before all the values in the textbox1 at the textbox1.exit event. But when i move out of the textbox1 the "$" sign diappears, But when i come to the same textbox again and press tab it appears again and this time the "$" sign stays after me exit the textbox1. Can any one please suggest me what should be the issues here. Why i am not gettting the value in $ amount for the first time when i move out of the textbox.

    rivate Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
        If Trim$(TextBox1.Text) = "" Then
           MsgBox ("Please enter the money.")
        End If
        
        TextBox1.Text = "$" & TextBox1.Text
        If Trim$(TextBox1.Text) = "$" Then TextBox1.Text = ""
    End Sub
    
    Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Select Case KeyAscii
        Case Asc("0") To Asc("9")
            Case Else
            KeyAscii = 0
    End Select
    'Madhan change ends
    End Sub
    
    Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    'Madhan Change starts
        If Trim$(TextBox1.Text) = "" Then
           TextBox1.Text = Trim$(TextBox1.Text)
        Else
            If InStr(1, Trim$(TextBox1.Text), "$") = 0 Then
                TextBox1.Text = "$" & TextBox1.Text
            End If
        End If
    'If Trim$(TextBox1.Text) = "$" Then TextBox1.Text = ""
    End Sub

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: $ sign disappears after the exit_Event fires for the first time

    Welcome to the Forum, unfortunately:

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1