Text into a VBA Text Box

D

donh

Hi,

I'm trying to create a touch screen keyboard so I can input a postcode/
zipcode into a user form (the users wont have a real keyboard). I've
got a basic one working where text typed goes into worksheet cells.
But I could really do with it going into a VBA Text box within the
user form in real time.

Any help as always appreciated


DonH
 
B

Bob Phillips

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H10" '<=== change to suit

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Userform1.Textbox1.Text = .value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

Couple of points.

The text enterd in the worksheet won't be transferred to the textbox until
it is Entered.

The form must be displayed modeless to allow worksheet input.

C hange the constant WS_RANGE value to your target cell, or a range of
cells.


--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
D

donh

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H10" '<=== change to suit

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Userform1.Textbox1.Text = .value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

Couple of points.

The text enterd in the worksheet won't be transferred to the textbox until
it is Entered.

The form must be displayed modeless to allow worksheet input.

C hange the constant WS_RANGE value to your target cell, or a range of
cells.

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)









- Show quoted text -

Thanks Bob but although it works as suggested users wont have a real
keyboard (hence making a virtual one) and therefore cant press enter.
Can the text go directly into the textbox? All finished form data
will be sent to another worksheet to form a database.

Many thanks


DonH
 
B

Bob Phillips

Don,

If they don't press Enter, how does Excel know that input is complete? And
how do the users move from cell to cell?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
D

donh

Don,

If they don't press Enter, how does Excel know that input is complete? And
how do the users move from cell to cell?
Bob,

This is for a survey form intended for a kiosk type environment where
everthing is completed on a user form via a touch screen, moving from
field to field by touching the next tick box on screen. I needed a
virtual keyboard so I could allow users to enter a post/zip code. I
have no proof it works, its just something I'm trying to get to work.

Don
 
B

Bob Phillips

Sorry, I completely misunderstood how it would work, I thought you had some
sort of other input device. I am afraid I have no experience of touch
screens, so I will probably be of no assistance.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
D

donh

Sorry, I completely misunderstood how it would work, I thought you had some
sort of other input device. I am afraid I have no experience of touch
screens, so I will probably be of no assistance.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)







- Show quoted text -

OK Many thanks for your help


DonH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top