Re: User form textbox issue
Probably because you put the code in the textbox's change event. How exactly are you sending the text to the form?
I'd add a public property to the form (e.g. dialogText) and use something like this to set the text:
Public Property Let dialogText(ByVal value As String)
me.TextBox1.text = value
End Property
Or if you are using a global for txt, then put the code in the initialize event of the form:
Private Sub UserForm_Initialize()
me.TextBox1.text = txt
End Sub
Re: User form textbox issue
I'm sending the text in in the vba code of the user form. When I right click on the form, one of the options is vba code.
As in my example. I added the line TextBox1.Text = txt:
Private Sub TextBox1_Change()
TextBox1.Text = txt
End Sub
Re: User form textbox issue
Quote:
Originally Posted by
kavkazi
I'm sending the text in in the vba code of the user form. When I right click on the form, one of the options is vba code.
As in my example. I added the line TextBox1.Text = txt:
Private Sub TextBox1_Change()
TextBox1.Text = txt
End Sub
But you are using the 'Change' event of the textbox, which only fires when the value changes. Hence, you only see the text when you start typing in the field (since that is the only time you are actually changing it's contents).
If you put the code in the initialize event for the form, it will set the text when the form loads. Try replacing your code with this:
Private Sub UserForm_Initialize()
me.TextBox1.text = txt
End Sub
Re: User form textbox issue
perfect .. works great.. thx
Re: User form textbox issue
in fact you do not need a global variable at all for this
vb Code:
Sub text()
dim txt as string
txt = Sheets("Sheet4").Cells(i, "B").Text & vbNewLine & _
Sheets("Sheet4").Cells(i, "C").Text & vbNewLine & _
Sheets("Sheet4").Cells(i, "D").Text & vbNewLine & _
Sheets("Sheet4").Cells(i, "E").Text & vbNewLine & _
Sheets("Sheet4").Cells(i, "F").Text & vbNewLine & _
Sheets("Sheet4").Cells(i, "H").Text & vbNewLine & vbNewLine
userform1.textbox1 = txt
UserForm1.Show
End Sub