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
Bookmarks