473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
1 2905
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: deko | last post by:
I'd like to use a bit of code in the OnOpen event of a report: =rptOpen(Me.ReportName), (Me.Tag) --this doesn't work This does work: Private Sub Report_Open(Cancel As Integer)...
5
by: GB | last post by:
Hello: In my MS Access project I have two objects - my form and my report. I need to pass variable value from Command_click procedure of my form to Report_open procedure of my report. How can I...
4
by: deko | last post by:
This is a basic program flow question. I'm trying to refractor an AC2000 app and split sections of code into separate modules. But there are a number of collections I create in one big module -...
7
by: TPS | last post by:
I don't want to use QueryString variables to pass data from page to page because the user can see and manipulate it. ( I know I can check for valid data, and I do). What other methods are...
1
by: Max | last post by:
I have my HTTPModule or HTTPHandler registered to process all file types (*). I have IIS configured to pass all requests to ASP.NET for this virtual directory. In some cases depending on the...
6
by: DMUM via AccessMonster.com | last post by:
Hello I am trying to pass the name of my subform to a function/sub but I can't seem to get it to work. I am using an autokey function (ctrl E) to unlock text boxes on a subform. I have a few...
12
by: MrHelpMe | last post by:
Hello again all, I've finished my whole application and now I don't like the whole session variables that I am using. I have a form, user fills in info clicks submit and using CDOSYSMail an...
9
by: grbgooglefan | last post by:
I am trying to pass a C++ object to Python function. This Python function then calls another C++ function which then uses this C++ object to call methods of that object's class. I tried...
4
by: Ed Bitzer | last post by:
Appreciate some direction as to what most of you professionals do when passing some limited variables to another form. A simple example would be passing the location of a second form. I could use...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.