Solved

500 POINTS - Using same form for multiple textbox input

Posted on 2010-08-18
7
343 Views
Last Modified: 2012-05-10
Hi,
   I have an on screen keyboard which I use for my touchscreen application.  On my form I have 8 testboxes called text1 to text8, I have a button which I press to launch an on screen keyboard.  What I want to do is use this same form to allow the user to enter characters in the various textboxes depending on which one is focused.

How can I do this?

Cheers
0
Comment
Question by:damianb123
7 Comments
 
LVL 18

Expert Comment

by:Anil Golamari
ID: 33468867
http://www.tek-tips.com/faqs.cfm?fid=6470  
You need to implement similar to the code in this code.

Hope it helps you

Good Luck.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 33469705
0
 
LVL 1

Accepted Solution

by:
Dymer2 earned 500 total points
ID: 33496657
Hi,
I dont know exactly what you mean with on-line keyboard. Is it a part of the same form as the textboxes or is it a separate form (from what it sounds you have created the online keyboard yourself).
My suggestion is:
trigger the doubleclick event for each textbox, store the textbox name in a global variable.
Depending on your online keyboard, enable it in the doubleclick event, and disable it on Enter or "OK" from your keyboard.

Good Luck!
Option Explicit
Dim Textbox As String
Dim ActiveKeyboard As Boolean
Dim Message As String
Private Sub Text1_DblClick()
    Textbox = Text1
    ActiveKeyboard = True
End Sub

Sub KeyboardClick(OnlineChar As String)
    If ActiveKeyboard Then
        If OnlineChar = vbCrLf Then
            Message = ""
            ActiveKeyboard = False
        Else
            Message = Message & OnlineChar
            Me.Controls(Textbox).Text = Message
        End If
    End If
End Sub

Open in new window

0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 3

Expert Comment

by:Genetic_Wolf
ID: 33613368

first...  as you've noticed (and know) when you TOUCH your "visual" keyboard, this TAKE the focus.
and you NEED to eitheir KEEP that focus or WRITE inside that "textbox"

The best way to handle the problem is first to remove all Textbox (to avoid very bad problem with focus) and replacing it with LABEL Box...
BorderStyle set to 1
background set to White

this will IMITATE a textbox.

I called mine lblTextBox
now I've set up an ARRAY of theses, so I have lblTextBox(0) and lblTextBox(1)
no limit in dimension.

when you HIT (screen click) a textbox, you'll need to change the reference ID of the CURRENT USED textbox.

then you apply a filter to send the key stroke to the emulation function.

give me a second, I'm writing the app.  should take less then 10 minutes.
0
 
LVL 3

Expert Comment

by:Genetic_Wolf
ID: 33613836
just a note:
I'm using the TAG attribute in my keyboard exemple, so I don't need to Align the CORRECT Array number wich is fastidius and need to be completely redone everytime you ADD or remove a Letter in the keyboard.
using the TAG attribute allow me to Set for exemple  the letter A to cmdMyKeyboard(0) and B to cmdMyKeyboard(77) or completely change the layout of my keyboard without the fuss of rewriting the app to change the array definition.

I've finally used Textbox instead of the proposed label, in order to be enable to have the "visual" effect of the cursor.  and I used the LOCKED attribute so the text is handle by code and not by real keyboard entry.   I've also removed the Tab Stop attribute to all textbox, in order to avoid a possible problem.  Since this App will be run with Touch Screen, the Tab function is not needed.
if you "need" the tabstop function, you'll need to ensure that glngFocussedTextBox stay syncronized.  it could be done with the Getfocus fonction.







KeyboardEx.zip
0
 
LVL 3

Expert Comment

by:Genetic_Wolf
ID: 33613850
I've written the remark as I programed and I forgot to revise it.
The TabStop have been re-instated in the Exemple, but to my opinion, if this will be ONLY a Touch Screen program with no use for Tab Key, you would be better removing that feature.  Although the current version of the exemple seem to be bug free from that.  There is note in the code how I fixed it with the GotFocus Event.

I've used only Number, but since the Tag Attribute is set as numerical, you can use any Keyboard function or letter  you'll like and since we're using an EMULATED keyboard, you can even ADD function that doesn't exist on a keyboard and implement it through code.
(exemple a button that will calculate copy or paste)

I didn't implement Select for cut and paste, but that's easyly done with the way I programmed the rest.
0
 

Author Closing Comment

by:damianb123
ID: 33733491
Great, this worked perfect.  Thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question