Click here to Skip to main content
15,888,351 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: db grid col width Pin
Jim Matthews9-Dec-04 8:25
Jim Matthews9-Dec-04 8:25 
QuestionReturn value from modal dialog? Pin
TAlvord8-Dec-04 10:03
TAlvord8-Dec-04 10:03 
AnswerRe: Return value from modal dialog? Pin
TAlvord10-Dec-04 9:57
TAlvord10-Dec-04 9:57 
Generalpassing variables between windows forms Pin
mpiotro8-Dec-04 8:51
mpiotro8-Dec-04 8:51 
GeneralRe: passing variables between windows forms Pin
Pablo.ar8-Dec-04 9:04
Pablo.ar8-Dec-04 9:04 
GeneralRe: passing variables between windows forms Pin
mpiotro8-Dec-04 9:14
mpiotro8-Dec-04 9:14 
GeneralRe: passing variables between windows forms Pin
Dave Kreskowiak8-Dec-04 10:28
mveDave Kreskowiak8-Dec-04 10:28 
GeneralRe: passing variables between windows forms Pin
Jim Matthews8-Dec-04 10:14
Jim Matthews8-Dec-04 10:14 
hi, looks to me like you're using .net based on the "handles" keyword in your method signature as well as a few other things, so i'll suggest another way for you. (no offense intended pablo! Smile | :) )

the best way to do this would be to set up a friend property on form1 one that gives access to a module level variable in form1. you'll also need a reference to the actual form1 object in form2. some thing like this...

public class form1
   inherits system.windows.forms.form

'initialization code

private m_productCode as String

friend property ProductCode() as String
   Get
      return me.m_productCode
   End Get
   Set(byval value as string)
      me.m_productcode = value
   End Set
end property

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

   me.ProductCode = textbox1.text.substring(0, 4)

   dim frmTwo as new form2
   frmTwo.FormOne = me
   frmTwo.Show

end sub

end class

*'--- in a separate code file ---'*

class form2
   Inherits System.Windows.Forms.Form

private m_formOne as Windows.Forms.Form

Friend Property Form1 as Windows.Forms.Form
   Get
      return me.m_formOne
   End Get
   Set(byval value as Windows.Forms.Form)
      me.m_formOne = value
   End Set
End Property

Private Sub form2_Load(byval sender as object, byval e as system.eventargs) handles form2.Load

'--- this line gives you access to the product code from form1 ---'
dim productCode as string = me.FormOne.ProductCode

End Sub

end class


the freind property in form2 gives form1 access to safely set a field in form2, and vice versa for the friend property in form1.

this code isn't tested and wasn't typed into my editor, so beware of syntaxtual errors. just a warning...

hope this helps



-jim
GeneralRe: passing variables between windows forms Pin
Pablo.ar8-Dec-04 14:20
Pablo.ar8-Dec-04 14:20 
GeneralRe: passing variables between windows forms Pin
Jim Matthews9-Dec-04 2:53
Jim Matthews9-Dec-04 2:53 
Generaldetecting/removing shared folders Pin
tutank738-Dec-04 7:52
tutank738-Dec-04 7:52 
GeneralPlace pictures in listview items (bigger than LargeIcons) Pin
evermood8-Dec-04 6:50
evermood8-Dec-04 6:50 
GeneralI am in Very bad position please Help (Runtime Error 430) Pin
sathiyaram8-Dec-04 6:43
sathiyaram8-Dec-04 6:43 
GeneralRe: I am in Very bad position please Help (Runtime Error 430) Pin
Peter938-Dec-04 7:04
Peter938-Dec-04 7:04 
GeneralRe: I am in Very bad position please Help (Runtime Error 430) Pin
sathiyaram8-Dec-04 20:36
sathiyaram8-Dec-04 20:36 
GeneralRe: I am in Very bad position please Help (Runtime Error 430) Pin
Peter939-Dec-04 6:36
Peter939-Dec-04 6:36 
GeneralRe: I am in Very bad position please Help (Runtime Error 430) Pin
Mekong River8-Dec-04 23:24
Mekong River8-Dec-04 23:24 
GeneralMailbox size Pin
Member 11070068-Dec-04 5:47
Member 11070068-Dec-04 5:47 
GeneralRe: Mailbox size Pin
Dave Kreskowiak8-Dec-04 7:07
mveDave Kreskowiak8-Dec-04 7:07 
GeneralRe: Mailbox size Pin
Member 11070068-Dec-04 7:10
Member 11070068-Dec-04 7:10 
GeneralRe: Mailbox size Pin
Dave Kreskowiak9-Dec-04 0:52
mveDave Kreskowiak9-Dec-04 0:52 
GeneralRe: Mailbox size Pin
Member 11070069-Dec-04 1:39
Member 11070069-Dec-04 1:39 
GeneralRe: Mailbox size Pin
Dave Kreskowiak9-Dec-04 4:39
mveDave Kreskowiak9-Dec-04 4:39 
GeneralRe: Mailbox size - here the solution Pin
Member 11070069-Dec-04 5:02
Member 11070069-Dec-04 5:02 
GeneralRemoting:SoapClientFormatterSink Pin
gscloete8-Dec-04 4:30
gscloete8-Dec-04 4:30 

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.