![]() |
Click here to advertise with us
|
|
|||||||
| Other Discussion on any other component not covered in a topic area above |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
this will probably be simple to answer for the right person, I have a form and I need to pass data to another form, I have decided to use a module to store the data I want to pass, here's what code resides on the first form:
Code:
Private Sub CreateNewEventOrAppointmentToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateNewEventOrAppointmentToolStripMenuItem.Click
Dim person_id As String
Dim calendar_id As String
person_id = TextBox6.Text
calendar_id = TextBox3.Text
get_person_id() = person_id
get_calendar_id() = calendar_id
frmEvent.Show()
Me.Hide()
End Sub
Code:
Module Module1
Private Sub get_person_id(ByVal person_id As String)
End Sub
Private Sub get_calendar_id(ByVal calendar_id As String)
End Sub
End Module
Also as a side note is this a good way to move data between forms???? |
|
||||
|
Make your two Subs Public rather than Private
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. Before posting your question, did you look here? Microsoft MVP 2005/2006/2007/2008/2009 |
|
|||
|
hiya i have now done that, but it still has a error on this line:
Code:
get_person_id() = person_id
get_calendar_id() = calendar_id
What ever that means....
|
|
||||
|
No equals sign. get_person_id is the name of the sub and person_id is the parameter you are passing it. person_id doesn't equal anything
Code:
get_person_id(person_id)
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. Before posting your question, did you look here? Microsoft MVP 2005/2006/2007/2008/2009 |
|
|||
|
i done it at last - so simple when u know how:
Code:
Dim person_id As String Dim calendar_id As String person_id = TextBox6.Text calendar_id = TextBox3.Text get_person_id(person_id) get_calendar_id(calendar_id) frmEvent.Show() Me.Hide() End Sub Code:
Module Module1
Public Sub get_person_id(ByVal person_id As String)
MsgBox("Your variable" & person_id)
End Sub
Public Sub get_calendar_id(ByVal calendar_id As String)
MsgBox("Your variable" & calendar_id)
End Sub
End Module
|
|
||||
|
Is this something you will need to call from multiple forms throughtout your project?
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. Before posting your question, did you look here? Microsoft MVP 2005/2006/2007/2008/2009 |
|
||||
|
The data isn't really stored. Each time you call it, you pass it what you want person_id to be.
It can be the same thing each time...it could be something different on each form every time you run it.
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. Before posting your question, did you look here? Microsoft MVP 2005/2006/2007/2008/2009 |
|
|||
|
ok, i understand a bit more...
so i have manage to get the data from my form1 to my module, now i need to read this data from another form...suppose it acts as a tempory place holder i think: heres the code i have on form2: Code:
Public Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim person_id As String
Dim calendar_id As String
Call set_person_id(person_id)
Call set_calendar_id(calendar_id)
MsgBox("Your variable " & person_id)
MsgBox("Your variable " & calendar_id)
End Sub
Code:
Module Module1
Public Sub get_person_id(ByVal person_id As String)
End Sub
Public Sub get_calendar_id(ByVal calendar_id As String)
End Sub
Public Sub set_person_id(ByVal person_id)
Return
End Sub
Public Sub set_calendar_id(ByVal calendar_id)
Return
End Sub
End Module
|
|
||||
|
I think we can simplify things by getting rid of the sub routines, and simply using public variables
Code:
Module Module1 Public person_id As String Public calendar_id As String End Module 'from somewhere on some form person_id = "mcfly" 'from somewhere else on any other form in your entire project Messagebox.Show(person_id)
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. Before posting your question, did you look here? Microsoft MVP 2005/2006/2007/2008/2009 |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|