Solved

sending data from form to form

Posted on 2004-04-07
10
224 Views
Last Modified: 2010-04-17
Hi there,

I have a mainform in which i have various text boxes. I have keypadform which is a keypad with buttons for A,B,C...etc.

When a user presses buttons in keypadform, the textbox in mainform which had focus should get the corresponding alphabet in it.

The Question is, How do know which textbox has focus becuase the mainform itself loses focus when the user is clicking on the keypadform.

Thanks,

Reddy.
0
Comment
Question by:preshitreddy
10 Comments
 
LVL 4

Expert Comment

by:PerryDK
ID: 10781280
what language are you using visual basic, visual MFC C++, C++ Builder, etc.   Need to know more information to answer the question.
0
 

Author Comment

by:preshitreddy
ID: 10781312
I am using VB.net
0
 
LVL 4

Expert Comment

by:PerryDK
ID: 10781339
ok sorry can't help you then :(
Its best to be specific when asking your questions so that experts know how to answer your question.

Sorry I can't help because I know very little of VB but you should be able to iterate through the components on your form and call some function that might be named something like HasFocus.  You might be better off asking in the Programming->Languages->Visual Basic Thread
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 10781406
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:Leroyski
ID: 10781956
You can simple refer to an object on another form as if you would on the same form. For example, imagine you have the textbox in the keypad form, then your code for button "a" would be something like:

text1.text = text1.text & "A"

Now, let's say you're in the keypad form, and you want to update the textbox on the other form, you can simple do this:

mainform.text1.text = mainform.text1.text & "A"
0
 
LVL 2

Expert Comment

by:JSMCM
ID: 10782206
This is a quick and dirty example.

You have two forms and a module.

On form 1 you have 3 text boxes(Text1, Text2 Text3), and a command button (Command1).

ON form 2 you have a command button (Command1).

Here is the Code For form 1

----------------------------------------
Option Explicit

Private Sub Command1_Click()
Form2.Show
End Sub

Private Sub Text1_GotFocus()
Set T = Text1

End Sub

Private Sub Text2_GotFocus()
Set T = Text2

End Sub

Private Sub Text3_GotFocus()
Set T = Text3

End Sub
----------------------------------------





Here is the Code For form2

----------------------------------------
Option Explicit

Private Sub Command1_Click()
T.Text = "DD"
End Sub

----------------------------------------







Here is the Code For the module
----------------------------------------
Option Explicit

Public T As TextBox

----------------------------------------




I am not going to explain, but if you need it please let me know,

John
0
 
LVL 27

Expert Comment

by:Dabas
ID: 10788125
Hi preshitreddy:
Try the following:

    Dim CurrentTextBox As TextBox
    Private Sub txtGotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Text1.GotFocus, Text2.GotFocus, TExt3.GotFocus' , add more textboxes if needed. This can also be done through code with AddHandler
        CurrentTextBox = CType(sender, TextBox)
    End Sub

Dabas
0
 

Author Comment

by:preshitreddy
ID: 10788902
Hi All,

I found the solution.

In my mainform, when I am initializing keypadform, i added,

Me.AddOwnedForm(KeypadForm)

In keypadform, when a button is clicked, I did,

Me.Owner.ActiveControl.Text = Me.Owner.ActiveControl.Text + myString

So whenever a user presses buttons in keypadform, the alphabet associated with that button (a,b,c,1,2,3 etc) shows up in the textbox which last had the focus in mainform.

Thanks for all the support guys.

0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 10820289
Closed, 50 points refunded.
Netminder
Site Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mergeTwo  challenge 13 84
mapAB Challlenge 35 126
how to update exe applicatio from internet ? 6 67
program a usb light to turn on when needed 6 49
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now