Access Form1.vb from Class.vb

Access Form1.vb from Class.vb

Anonymous
Not applicable
406 Views
2 Replies
Message 1 of 3

Access Form1.vb from Class.vb

Anonymous
Not applicable
I have a class file and a Form1.vb file in my project.
I need to read the values of Form1.vb (example: value of textbox1.text in Form1.vb) from my class.
Somehow I am getting nothing returned when I try to acces the values on the form.
I guess it's because I am having the following statement in my class:
_
Public Sub NewCmd1()
Dim myForm As New Form1
Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(myForm)
End Sub

_
Public Sub MessageboxTest()
Messagebox.show(myForm.Textbox1.text)
Messagebox.show(myForm.Combobox.text)
End Sub

If I call MessageboxTest(), the values are nothing.
If I don't declare "Dim myForm As New Form1" I cannot get the form to display, but if I do this, I cannot get
the value of any of the comboboxes or textboxes. Can anybody help ?
0 Likes
407 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
If you declare a variable in one sub it is not available in another sub. You need to declare the variable outside the subs.
0 Likes
Message 3 of 3

Anonymous
Not applicable
You need to create public properties for this:



In your Form1.vb class:



Public ReadOnly Property MyText As String

Get

return textBox1.text

End Get

End Property



then you can access that property from outside the Form class...



--

http://cupocadnet.blogspot.com



Edited by: bertvan on Mar 5, 2009 9:15 PM
Edited by: bertvan on Mar 7, 2009 5:33 PM
0 Likes