Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Multiple Forms + textBox


Reply
 
Thread Tools Display Modes
  #1  
Old 09-08-2004, 11:10 AM
ScientificLee ScientificLee is offline
Centurion
 
Join Date: Sep 2003
Posts: 118
Default Multiple Forms + textBox


Hi.

I have a main form that receives data.
When certain conditions are met it calls a function to send messages to the end users. Something else I would like it to do is call a function, WriteInfo(tracker as string, barrier as string).

Code:
Private Sub WriteToInfo(ByVal tracker As String, ByVal barrier As String) Dim info As New Form2 info.Show() End Sub

The function should just write out information to a floating text box. Not sure how I should go about this. I guess I should first check if Form2 already exists. If it does just write to it. Although I'm not sure how to do this because I usually just pass in the variable when I initiate the other form.

Any ideas?
Reply With Quote
  #2  
Old 09-08-2004, 01:21 PM
Allen G's Avatar
Allen G Allen G is offline
Centurion
 
Join Date: Jul 2004
Location: Arlington, Texas
Posts: 189
Default

Quote:
Originally Posted by ScientificLee
Hi.

I have a main form that receives data.
When certain conditions are met it calls a function to send messages to the end users. Something else I would like it to do is call a function, WriteInfo(tracker as string, barrier as string).

Code:
Private Sub WriteToInfo(ByVal tracker As String, ByVal barrier As String) Dim info As New Form2 info.Show() End Sub

The function should just write out information to a floating text box. Not sure how I should go about this. I guess I should first check if Form2 already exists. If it does just write to it. Although I'm not sure how to do this because I usually just pass in the variable when I initiate the other form.

Any ideas?
This is a pain for me aswell. The only thing I have found to work is:
Code:
Public Shared Sub UpdateStatus(Optional ByVal newStatus As String = "") CType(frmLogin.ActiveForm, frmLogin).sbLoginStatus.Panels(0).Text = newStatus End Sub
Something like that. (This must be placed within the Form Class.)
Reply With Quote
  #3  
Old 09-08-2004, 02:21 PM
ScientificLee ScientificLee is offline
Centurion
 
Join Date: Sep 2003
Posts: 118
Default

I'll try that. The C# solution seems more elegant. Just call the function that updates the string value.
Reply With Quote
  #4  
Old 09-09-2004, 02:49 AM
liwo's Avatar
liwo liwo is offline
Centurion
 
Join Date: Oct 2003
Location: Germany
Posts: 116
Default

I would declare a variable on class level in your Form1 for Form2:
Private info As Form2

So your sub would be this:
Code:
Private Sub WriteToInfo(ByVal tracker As String, ByVal barrier As String) If info Is Nothing Then info = New Form2 info.Show() End If End Sub

To write information to a textbox in Form2 you can either add a method for it to Form2 or you can just acces info.Textbox1.Text and write the info there
__________________
Please use [vb][/vb] Tags instead of [code][/code] Tags when posting VB Code. Thank you.
Reply With Quote
  #5  
Old 09-09-2004, 09:00 AM
ScientificLee ScientificLee is offline
Centurion
 
Join Date: Sep 2003
Posts: 118
Default

info.textbox1.text doesn't seem to work correctly when done from Form1.
Reply With Quote
  #6  
Old 09-09-2004, 09:32 AM
ScientificLee ScientificLee is offline
Centurion
 
Join Date: Sep 2003
Posts: 118
Default

Nevermind. Was something else. Thanks
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->