467,138 Members | 1,334 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,138 developers. It's quick & easy.

Don't know how to pass data from form to module

Here is the offending excerpt from my code. I just began trying to
port some vb code I'd written into my first .NET app.

Public Class bannergenerator 'THIS IS AN ORDINARY WINDOWS FORM
Inherits System.Windows.Forms.Form
Friend strINPUTFILE 'STRING TO HOLD INPUT FILE NAME
Public objOpenfile

<..code defining the form>

'THIS IS CODE THAT OPENS AN OPEN FILE DIALOGUE WHEN YOU CLICK A BUTTON,
'STORES THE SELECTED FILE INTO A TEXT BOX,
'AND IS SUPPOSED TO STORE IT INTO A STRING "strINPUTFILE" as well

Sub btnSelect_Inputs_File_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnSelect_Inputs_File.Click
Dim objOpenfile As New OpenFileDialog
objOpenfile.Multiselect() = False
If objOpenfile.ShowDialog = DialogResult.OK Then
tboxSelectInputs.Text = objOpenfile.FileName 'tranfer the
selected file name to a text box
strINPUTFILE = tboxSelectInputs.Text
End If
End Sub

End Class

My problem with the above code is that the "strINPUTFILE" variable does
not appear to be receiving the value from "tboxSelectInputs.Text",
although "tboxSelectInputs.Text" is finding the correct selected file
value. Also, the "strINPUTFILE" variable shows up as undeclared when
it is referenced in another module in the same project, although I've
declared it a Friend outside of any sub in its class. What don't I
understand?

Best regards and thanks for any help.

May 23 '06 #1
  • viewed: 2663
Share:
1 Reply
If you want to use a variable like strINPUTFILE, I would declare that in a
Standard Module as Public strINPUTFILE As String

Another option would be to create a property in Class bannergenerator

where you could Set/Get values from the class object.

Regards,
Rich

"mg********@hotmail.com" wrote:
Here is the offending excerpt from my code. I just began trying to
port some vb code I'd written into my first .NET app.

Public Class bannergenerator 'THIS IS AN ORDINARY WINDOWS FORM
Inherits System.Windows.Forms.Form
Friend strINPUTFILE 'STRING TO HOLD INPUT FILE NAME
Public objOpenfile

<..code defining the form>

'THIS IS CODE THAT OPENS AN OPEN FILE DIALOGUE WHEN YOU CLICK A BUTTON,
'STORES THE SELECTED FILE INTO A TEXT BOX,
'AND IS SUPPOSED TO STORE IT INTO A STRING "strINPUTFILE" as well

Sub btnSelect_Inputs_File_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnSelect_Inputs_File.Click
Dim objOpenfile As New OpenFileDialog
objOpenfile.Multiselect() = False
If objOpenfile.ShowDialog = DialogResult.OK Then
tboxSelectInputs.Text = objOpenfile.FileName 'tranfer the
selected file name to a text box
strINPUTFILE = tboxSelectInputs.Text
End If
End Sub

End Class

My problem with the above code is that the "strINPUTFILE" variable does
not appear to be receiving the value from "tboxSelectInputs.Text",
although "tboxSelectInputs.Text" is finding the correct selected file
value. Also, the "strINPUTFILE" variable shows up as undeclared when
it is referenced in another module in the same project, although I've
declared it a Friend outside of any sub in its class. What don't I
understand?

Best regards and thanks for any help.

May 24 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by DMUM via AccessMonster.com | last post: by
4 posts views Thread by Ed Bitzer | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.