How to write the code to a command button to paste text?
Dear Friends,
I have to write code to the command button for the following use.
I have a command button called "cmdDetails". when I press this button it should enter the following text in a textbox called "txtDetails". The property of this textbox is set to "Multiline".
The following is the text to be entered automatically in a single textbox (which has the multiline property set as TRUE) when the cmdDetails button is pressed:
Currency : Dollor
Conversion : Rs. 45
Invoice Amount : $ 100
Invoice Amount : Rs. 4500
Thanks in advance.
Re: How to write the code to a command button to paste text?
Is this what you are after?
make sure the textbox height is enough or set the verticle scrollbar to true
Code:
Private Sub cmdDetails_Click()
txtdetails.Text = "Currency : Dollor" & vbCrLf & _
"Conversion : Rs. 45" & vbCrLf & _
"Invoice Amount : $100" & _
"Invoice Amount : Rs. 45"
End Sub
Re: How to write the code to a command button to paste text?
...or if you want to insert the text use the SelText property instead of the Text property. If you want to add the text to the end of the textbox set the SelStart property to the length of the text in the textbox (see below) before setting the SelText property.
Code:
With txtDetails
.SelStart = Len(.Text)
.SelText = "Currency: Dollar" & vbCrLf & "Conversion ...."
End With