Click here to Skip to main content
15,923,015 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Rotating Dice Pin
Anonymous16-Mar-04 9:13
Anonymous16-Mar-04 9:13 
GeneralRe: Rotating Dice Pin
Dave Kreskowiak16-Mar-04 9:28
mveDave Kreskowiak16-Mar-04 9:28 
GeneralRe: Rotating Dice Pin
RBCC16-Mar-04 9:39
RBCC16-Mar-04 9:39 
GeneralRe: Rotating Dice Pin
Dave Kreskowiak17-Mar-04 5:35
mveDave Kreskowiak17-Mar-04 5:35 
GeneralRe: Rotating Dice Pin
FruitBatInShades16-Mar-04 22:35
FruitBatInShades16-Mar-04 22:35 
GeneralControl inside datagrid Pin
BlomEng15-Mar-04 21:43
BlomEng15-Mar-04 21:43 
Generaltext from form1 to form 2 Pin
ineedhelp15-Mar-04 21:35
ineedhelp15-Mar-04 21:35 
GeneralRe: text from form1 to form 2 Pin
Dave Kreskowiak16-Mar-04 2:42
mveDave Kreskowiak16-Mar-04 2:42 
xtremean wrote:
i've never come across how to get the string in a text box on one form another text box/label/whatever on another form.

That's because your thinking about the code on one form directly manipulating the controls on another form. The reason you don't see that in the books is because it's bad practice.

What you should be thinking about is having public variables somewhere that both forms can access. For example, you have two forms, one has a string that needs to be passed to the second. The first form just has a label, a textbox and a button on it:
Public Class Form1
    Inherits System.Windows.Forms.Form
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim newForm As New Form2
 
        newForm.strDataThisFormNeeds = TextBox1.Text
        newForm.Show()
    End Sub
End Class

Form1 is simple, just type something in the textbox and click a button to send the string to Form2. The code in the button click just creates a new instance of Form2 and set the public variable that Form2 exposes to the string in Form1's textbox. Form2 just has a label and a textbox on it and exposes a public string like this:
Public Class Form2
    Inherits System.Windows.Forms.Form
 
    Public strDataThisFormNeeds As String
 
    Private Sub Form2_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
        TextBox1.Text = strDataThisFormNeeds
    End Sub
End Class

This is just a VERY simple example and does NOT show all the possible methods of passing data between forms!


RageInTheMachine9532
GeneralCurious!All my linkbutton disappeared,why! Pin
BigGirlBigEyes15-Mar-04 19:18
BigGirlBigEyes15-Mar-04 19:18 
GeneralRe: Curious!All my linkbutton disappeared,why! Pin
FruitBatInShades16-Mar-04 22:46
FruitBatInShades16-Mar-04 22:46 
GeneralBecome nuts with ToolBar Pin
sybux200015-Mar-04 11:33
sybux200015-Mar-04 11:33 
GeneralRe: Become nuts with ToolBar Pin
Syed Abdul Khader16-Mar-04 20:21
Syed Abdul Khader16-Mar-04 20:21 
GeneralRe: Become nuts with ToolBar Pin
sybux200017-Mar-04 10:16
sybux200017-Mar-04 10:16 
GeneralRe: Become nuts with ToolBar Pin
Syed Abdul Khader19-Mar-04 21:25
Syed Abdul Khader19-Mar-04 21:25 
GeneralCash Registers Question ! Pin
Member 52593915-Mar-04 10:47
Member 52593915-Mar-04 10:47 
GeneralRe: Cash Registers Question ! Pin
Dave Kreskowiak15-Mar-04 11:12
mveDave Kreskowiak15-Mar-04 11:12 
GeneralRe: Cash Registers Question ! Pin
Wayne Phipps16-Mar-04 8:46
Wayne Phipps16-Mar-04 8:46 
GeneralHide text Tab in a TabControl Pin
sybux200015-Mar-04 8:30
sybux200015-Mar-04 8:30 
GeneralRe: Hide text Tab in a TabControl Pin
Dave Kreskowiak15-Mar-04 9:10
mveDave Kreskowiak15-Mar-04 9:10 
GeneralRe: Hide text Tab in a TabControl Pin
sybux200015-Mar-04 11:29
sybux200015-Mar-04 11:29 
GeneralCopy object from clipboard to file Pin
Member 77096915-Mar-04 6:37
Member 77096915-Mar-04 6:37 
GeneralRe: Copy object from clipboard to file Pin
Dave Kreskowiak15-Mar-04 6:55
mveDave Kreskowiak15-Mar-04 6:55 
GeneralRe: Copy object from clipboard to file Pin
Member 77096916-Mar-04 0:29
Member 77096916-Mar-04 0:29 
GeneralRe: Copy object from clipboard to file Pin
Dave Kreskowiak16-Mar-04 2:23
mveDave Kreskowiak16-Mar-04 2:23 
GeneralRe: Copy object from clipboard to file Pin
Anonymous16-Mar-04 7:18
Anonymous16-Mar-04 7:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.