Adding a string on KeyPress 
Author Message
 Adding a string on KeyPress

Hi
Got some problem's again
I come from the Visual Basic enviroment
Do'es anyone know the equivalent in VBA

Add the string to the listbox from a textbox on keypress

Private Sub txtAddTyp_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
  If KeyAscii = 13 Then
    listbox.AddItem text.Text
  End If

End Sub

--

Jon



Wed, 18 Jun 1902 08:00:00 GMT  
 Adding a string on KeyPress
Hi Jon,

in a class module
declare:

Public WithEvents Txtbox1 As MSForms.TextBox

which will show in the two drop-down boxes the respective events for a
textbox.
From there you can select:

Private Sub Txtbox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'....
End Sub

Hope this helps

Stratos

Quote:

> Hi
> Got some problem's again
> I come from the Visual Basic enviroment
> Do'es anyone know the equivalent in VBA

> Add the string to the listbox from a textbox on keypress

> Private Sub txtAddTyp_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
>   If KeyAscii = 13 Then
>     listbox.AddItem text.Text
>   End If

> End Sub

> --

> Jon




Wed, 18 Jun 1902 08:00:00 GMT  
 Adding a string on KeyPress

Sorry Jon ,
I think I misunderstood your question (I do it quite often I'm afraid).

The form level event I discribed above is valid and useful if you want to
work with all textboxes (or other control) as a group but necessery for
your problem (I think,,,)

I think that the normal :

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)

End Sub

event in the UserForm module (double click on the textbox image to see a
default event and then choose the one above in the drop-down box) is
adequate.

Sorry,

Stratos

Quote:

> Hi Jon,

> in a class module
> declare:

> Public WithEvents Txtbox1 As MSForms.TextBox

> which will show in the two drop-down boxes the respective events for a
> textbox.
> From there you can select:

> Private Sub Txtbox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
> '....
> End Sub

> Hope this helps

> Stratos


> > Hi
> > Got some problem's again
> > I come from the Visual Basic enviroment
> > Do'es anyone know the equivalent in VBA

> > Add the string to the listbox from a textbox on keypress

> > Private Sub txtAddTyp_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
> >   If KeyAscii = 13 Then
> >     listbox.AddItem text.Text
> >   End If

> > End Sub

> > --

> > Jon




Wed, 18 Jun 1902 08:00:00 GMT  
 Adding a string on KeyPress
Thanks for your help

Jon



Quote:
> Hi Jon,

> in a class module
> declare:

> Public WithEvents Txtbox1 As MSForms.TextBox

> which will show in the two drop-down boxes the respective events for a
> textbox.
> From there you can select:

> Private Sub Txtbox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
> '....
> End Sub

> Hope this helps

> Stratos


> > Hi
> > Got some problem's again
> > I come from the Visual Basic enviroment
> > Do'es anyone know the equivalent in VBA

> > Add the string to the listbox from a textbox on keypress

> > Private Sub txtAddTyp_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
> >   If KeyAscii = 13 Then
> >     listbox.AddItem text.Text
> >   End If

> > End Sub

> > --

> > Jon




Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Exel VB, How to add black string to coloured string in cell

2. Exel VB, How to add black string to coloured string in cell

3. Code - Add Secret KeyPress to Stop running.

4. Exel VB, How to add black string to coloured string in cell

5. Subject line string of SendObject adding garbage to end of string

6. Take one part of a string and add another part

7. Macro adding data string

8. How can I add elements to a string ?

9. VBA: problem with adding " into string variable

10. XL automation: adding a string to a cell


 
Powered by phpBB® Forum Software © phpBB Group