I tried
Public zText as String in form1, but form2 cant read it (undeclared)
what am i doing wrong?
I tried
Public zText as String in form1, but form2 cant read it (undeclared)
what am i doing wrong?
You need to create a public class so that it becomes a shared member: as in:
Public Class Result
Public Shared Msg As String
End Class
then in one form:
Result.msg = "set to my values"
and in the other form interrogating the string
my string = result.msg
You do not need to create an instance of the class, it is there for any other class / form to use and the Public Shared can be anything you want, even an object. Take the time to read up on shared members, one of the most useful aspects of VB .Net
no luck..
at the bottom of the code in form1 i have this
End Class 'End form1's class
Public Class Result
Public Shared InfoAbout As String
End Class
and then on a listview doubleclick i have
Dim Frm3 As New Form3()
Result.InfoAbout = LVW.SelectedItems.Item(0).Text
Frm3.Show()
and in form3 load, i have
MsgBox(Result.InfoAbout)
i get a blank string..
How can you have a selecteditem before you've even shown the form?
wha?Quote:
Originally posted by Edneeis
How can you have a selecteditem before you've even shown the form?
This is the code used to create the public class. the 'end class' at the beginning shows form1's end class - it just demonstrates i put the new class after the form1 class.VB Code:
End Class 'End form1's class Public Class Result Public Shared InfoAbout As String End Class
this code is in form1, on a listview double click i load up form3. i want to send the selected item text variable to form3 so it can read it.VB Code:
Dim Frm3 As New Form3() Result.InfoAbout = LVW.SelectedItems.Item(0).Text Frm3.Show()
this is the code in form3's form_load. it msgboxes an empty string.VB Code:
MsgBox(Result.InfoAbout)
got it :)