Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > Components & Controls > Other

Other Discussion on any other component not covered in a topic area above

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-09-2010, 7:38 AM
VB.NET Forum Enthusiast
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jun 2009
Posts: 38
Reputation: 12
mcfly is on a distinguished programming path ahead
Default moving data between forms using module

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
All I want to do is call a procedure and the data be sent to themodule, and the data to be stored for when I next need it on the second form, here's what i have but doesn't seem to work:


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
As you can tell I am very new to vb.net, but I am hopefully on the right lines and somebody will understand what I mean and can help further.

Also as a side note is this a good way to move data between forms????
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-09-2010, 8:25 AM
Hack's Avatar
VB.NET Forum Master
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Apr 2009
Location: Sterling Heights, MI
Age: 59
Posts: 313
Reputation: 0
Hack an unknown entityHack an unknown entityHack an unknown entityHack an unknown entity
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-09-2010, 8:36 AM
VB.NET Forum Enthusiast
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jun 2009
Posts: 38
Reputation: 12
mcfly is on a distinguished programming path ahead
Default

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
Says 'Argument not specified for parameter 'person_id of 'Public Sub get_perso(person_id As String)

What ever that means....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-09-2010, 8:39 AM
Hack's Avatar
VB.NET Forum Master
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Apr 2009
Location: Sterling Heights, MI
Age: 59
Posts: 313
Reputation: 0
Hack an unknown entityHack an unknown entityHack an unknown entityHack an unknown entity
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-09-2010, 8:42 AM
VB.NET Forum Enthusiast
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jun 2009
Posts: 38
Reputation: 12
mcfly is on a distinguished programming path ahead
Default

i done it at last - so simple when u know how:

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

    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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-09-2010, 8:42 AM
Hack's Avatar
VB.NET Forum Master
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Apr 2009
Location: Sterling Heights, MI
Age: 59
Posts: 313
Reputation: 0
Hack an unknown entityHack an unknown entityHack an unknown entityHack an unknown entity
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-09-2010, 10:50 AM
VB.NET Forum Enthusiast
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jun 2009
Posts: 38
Reputation: 12
mcfly is on a distinguished programming path ahead
Default

yes, is this a good way of doing this and how would you call the data thats stored?...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-09-2010, 10:54 AM
Hack's Avatar
VB.NET Forum Master
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Apr 2009
Location: Sterling Heights, MI
Age: 59
Posts: 313
Reputation: 0
Hack an unknown entityHack an unknown entityHack an unknown entityHack an unknown entity
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-09-2010, 11:43 AM
VB.NET Forum Enthusiast
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jun 2009
Posts: 38
Reputation: 12
mcfly is on a distinguished programming path ahead
Default

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
heres the module


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 am going slightly wrong within my code for calling the data?? But am not sure where...???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-09-2010, 11:55 AM
Hack's Avatar
VB.NET Forum Master
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Apr 2009
Location: Sterling Heights, MI
Age: 59
Posts: 313
Reputation: 0
Hack an unknown entityHack an unknown entityHack an unknown entityHack an unknown entity
Default

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)
Same same with calendar_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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 12:32 AM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.