10 Replies - 15050 Views - Last Post: 15 May 2010 - 01:00 PM Rate Topic: -----

#1 sgrahg   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 07-April 10

send item in one form to another form

Posted 07 April 2010 - 06:37 PM

im doing a project in vb 2008 with 5 forms. i need form 2, 3, and 4 to send an item that is doubleclick in a listbox in those forms to a listbox in form 5. can anyone help me. thanks
Is This A Good Question/Topic? 0
  • +

Replies To: send item in one form to another form

#2 demausdauth   User is offline

  • D.I.C Addict
  • member icon

Reputation: 190
  • View blog
  • Posts: 692
  • Joined: 03-February 10

Re: send item in one form to another form

Posted 08 April 2010 - 06:42 AM

So what have you got so far?
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: send item in one form to another form

Posted 08 April 2010 - 08:32 AM

Sorry but we can not give you the entire code to solve your problem. We are here to assist in solving problems with code you have written, with any error messages you are getting or what isn't working the way that you expect it to, we would be more than happy to help you with those problems. If there is a topic that you don't understand we would be more than happy to help you with that as well. Make sure to post any code with in code tags like below.

:code:

Be sure to visit our tutorial and snippet areas or read the FAQS at the top of the forums. Also, take a moment to read the rules about posting topics.

Thank you for helping us to help you solve your problem.
Was This Post Helpful? 0
  • +
  • -

#4 sgrahg   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 07-April 10

Re: send item in one form to another form

Posted 08 April 2010 - 10:36 AM

i change it alittle bit i doubleclick in 1 listbox to a cart listbox on same form and want to send all the items in cart listbox to form 5 cart listbox.

in form 2 i have code in button_click:

totalForm.Text = Me.cartListBox.Text
totalForm.Show()

in form 5 totalform i have code:

Private mText As String

Public Property Text1() As String
Get
Return mText
End Get
Set(ByVal Value As String)
mText = Value
Me.cartListBox1.Text = Value
End Set

End Property

can't get the text to display in form 5

thanks
Was This Post Helpful? 0
  • +
  • -

#5 ZRonZ   User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 207
  • Joined: 09-January 09

Re: send item in one form to another form

Posted 08 April 2010 - 02:41 PM

totalForm.Text = Me.cartListBox.Text
totalForm.Show()



In form 5 you should be able to refer to cartListBox.Text as "Form2.cartListBox.Text".

If you really need the totalFrom.Text for some reason that's not obvious in the code you supplied, you can keep the line "totalFrom.Text = Me.cartListBoxt.Text" in form2 and use form2.totalFrom.Text in the Form 5 code.

This post has been edited by ZRonZ: 08 April 2010 - 02:42 PM

Was This Post Helpful? 0
  • +
  • -

#6 sgrahg   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 07-April 10

Re: send item in one form to another form

Posted 08 April 2010 - 04:26 PM

that didn't work zronz. i have the button set up so that

totalForm.Text = Me.cartListBox.Text
totalForm.Show()

sends the cartlistbox contents in form 2 to form 5 where

a class in form 5 gets and sets the value and the code

Me.cartListBox1.Text = Value

sends the value to cartlistbox1 in form 5

aleast thats what i'm tring to do anyway, any ideas
Was This Post Helpful? 0
  • +
  • -

#7 ZRonZ   User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 207
  • Joined: 09-January 09

Re: send item in one form to another form

Posted 08 April 2010 - 05:26 PM

I created a two form project. Form1 has a listbox and a button. Form2 has a text box.

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.Visible = True
        Form2.TextBox1.Text = Me.ListBox1.SelectedItem
    End Sub
End Class


Public Class Form2

End Class



Select an item in the listbox on form1, press the button in Form1 and Form2 has the selected item in the textbox. Same if I change Me.ListBox1.selected item to Me.ListBox2.text

Technically I'm not "sending" anything. I'm just calling existing variables in the project.

Repost what you have. I'm missing something from your code...
Was This Post Helpful? 0
  • +
  • -

#8 sgrahg   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 07-April 10

Re: send item in one form to another form

Posted 08 April 2010 - 08:03 PM

still cant't get it to do it zronz here is everything

this is form 1

Public Class buyBicyclesForm
Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Hide()
End Sub

Public Sub buyBicyclesForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Displays items in buyBicyclesListBox
With Me.buyBicyclesListBox.Items
.Add("men's Forge Mountain Bike--$380.00")
.Add("Ladie's Magna Great Divide Bike--$99.99")
.Add("Triron Pro Ultimate 3-Wheeled Bike--$349.99")
.Add("Girl's Schwinn Bike--$99.99")
.Add("Boy's Mongoose Bike--$149.99")
End With
End Sub

Public Sub checkoutButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles checkoutButton.Click
totalForm.Visible = True
totalForm.cartListBox1.Text = Me.cartListBox.Text
totalForm.Show()
End Sub

Public Sub cartBoxLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Public Sub buyBicyclesListBox_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles buyBicyclesListBox.DoubleClick
'Sends items from buyBicyclesListBox to cartListBox when double clicked

cartListBox.Items.Add(buyBicyclesListBox.SelectedItem)
End Sub

Public Sub cartListBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cartListBox.SelectedIndexChanged

End Sub

Private Sub clearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearButton.Click
' Clear the list box.

Me.cartListBox.Items.Clear()
End Sub

Private Sub itemRemovButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles itemRemovButton.Click
'Removes one item from cartListBox

If cartListBox.SelectedIndex <> -1 Then
cartListBox.Items.Remove(cartListBox.Text)
Else
MessageBox.Show("You must first select an item to remove it!")
End If
End Sub



End Class


here is form 2

Public Class totalForm
Private Sub totalForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Hide()
End Sub

Private Sub clearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearButton.Click
' Clear the list box.
Me.cartListBox1.Items.Clear()
End Sub

Private Sub itemsBoxLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub


Private Sub clearItemButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearItemButton.Click
'Removes one item from cartListBox

If cartListBox1.SelectedIndex <> -1 Then
cartListBox1.Items.Remove(cartListBox1.Text)
Else
MessageBox.Show("You must first select an item to remove it!")
End If
End Sub

Private Sub cartListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cartListBox1.SelectedIndexChanged

End Sub
End Class

maybe i need to do something in one of the forms property box thanks
Was This Post Helpful? 0
  • +
  • -

#9 Guest_parul jain*


Reputation:

Re: send item in one form to another form

Posted 12 May 2010 - 11:32 AM

View PostZRonZ, on 08 April 2010 - 04:26 PM, said:

I created a two form project. Form1 has a listbox and a button. Form2 has a text box.

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.Visible = True
        Form2.TextBox1.Text = Me.ListBox1.SelectedItem
    End Sub
End Class


Public Class Form2

End Class



Select an item in the listbox on form1, press the button in Form1 and Form2 has the selected item in the textbox. Same if I change Me.ListBox1.selected item to Me.ListBox2.text

Technically I'm not "sending" anything. I'm just calling existing variables in the project.

Repost what you have. I'm missing something from your code...










THANK YOU VERY MUSH.....ITS VERY VERY HELPFULL TO ME.....
Was This Post Helpful? 0

#10 Luc001   User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 617
  • Joined: 04-May 09

Re: send item in one form to another form

Posted 12 May 2010 - 12:16 PM

Hi,

I think this part of code:

Public Sub buyBicyclesListBox_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles buyBicyclesListBox.DoubleClick
'Sends items from buyBicyclesListBox to cartListBox when double clicked

cartListBox.Items.Add(buyBicyclesListBox.SelectedItem)
End Sub


Should be more something like this:

Public Sub buyBicyclesListBox_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles buyBicyclesListBox.DoubleClick
'Sends items from buyBicyclesListBox to cartListBox when double clicked

  NameofyourForm2.cartListBox.Items.Add(buyBicyclesListBox.SelectedItem) ' this should changed
End Sub

Was This Post Helpful? 0
  • +
  • -

#11 citricube   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 73
  • Joined: 21-January 08

Re: send item in one form to another form

Posted 15 May 2010 - 01:00 PM

The easiest way to transfer data between forms that i find
would be using a Module. I would just create a module like
Module Module1
    Friend someString As String
End Module



and then you can access the variable someString from
both Form1's class and Form2's class just remember
to declare Module variables with Friend as opposed to
dim.



View PostLuc001, on 12 May 2010 - 11:16 AM, said:

Hi,

I think this part of code:

Public Sub buyBicyclesListBox_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles buyBicyclesListBox.DoubleClick
'Sends items from buyBicyclesListBox to cartListBox when double clicked

cartListBox.Items.Add(buyBicyclesListBox.SelectedItem)
End Sub


Should be more something like this:

Public Sub buyBicyclesListBox_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles buyBicyclesListBox.DoubleClick
'Sends items from buyBicyclesListBox to cartListBox when double clicked

  NameofyourForm2.cartListBox.Items.Add(buyBicyclesListBox.SelectedItem) ' this should changed
End Sub

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1