Welcome to Dream.In.Code
Become a VB Expert!

Join 137,230 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,887 people online right now. Registration is fast and FREE... Join Now!




radio buttons and listbox

 
Reply to this topicStart new topic

radio buttons and listbox

bflyroses
13 Mar, 2007 - 12:06 PM
Post #1

New D.I.C Head
*

Joined: 13 Mar, 2007
Posts: 3


My Contributions
Hi I need some help I am trying to connect my radio buttons to show prices in the listbox with the name of the movie selected this is what I have so far
my problem is I don't know how to get the selected radio button to output to the listbox or the name of selected movie to also display I have tried if statements included in my with statement doesn't work I set up my radiobutton control all in one event (6 of them and they are already working to display prices in my label but I am stumped on how to output to listbox
CODE

Image1 = Image.FromFile("mm.jpg")
        lblPic.Image = Image1
        'opens and displays movie title choices
        Dim movie(9) As String
        Dim price(9) As String
        Dim sr As IO.StreamReader = IO.File.OpenText("Movies.txt")
        Dim arrMovie As Integer = 0
        Do While (sr.Peek() <> -1)
            movie(arrMovie) = sr.ReadLine
            price(arrMovie) = sr.ReadLine
            cboMovie.Items.Add(movie(arrMovie))
            arrMovie = arrMovie + 1
            
        Loop
        sr.Close()



        lblDate.Text = DateTime.Now.ToLongDateString





        sr.Close()
    End Sub


    Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
        Dim strTotal As String
        Dim strDisTotal As String

        Dim strFormat As String = "{0:C}" & ControlChars.Tab & "{1:N}"
        Dim strLine As String = "-"



        decSubTotal = Reg_Price * City_Tax

        decTotal = decSubTotal + Reg_Price
        decSubDisTotal = Discount_Price * City_Tax

        decDisTotal = decSubDisTotal + Discount_Price
        decReg = Reg_Price
        decTax = City_Tax
        decDis = Discount_Price

        With lstTransHistory
            lstTransHistory.Items.Clear()
            strTotal = (decTotal + Reg_Price).ToString("c")
            strDisTotal = (decDisTotal + Discount_Price).ToString("c")
            lstTransHistory.Items.Add(String.Format(strFormat, "Movie", "Quantity", "Price"))
            lstTransHistory.Items.Add("-----------------------------------------------------")

            lstTransHistory.Items.Add(String.Format(strFormat, "Total", (strTotal)))
        

        End With
  
        

    End Sub

User is offlineProfile CardPM
+Quote Post

Jayman
RE: Radio Buttons And Listbox
13 Mar, 2007 - 01:32 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,984



Thanked: 44 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
You can do that by using the Checked Property to determine which radiobutton is selected.

To give you an idea of what I mean:
CODE

If radiobutton1.Checked Then
   'add title to listbox
Else If radiobutton2.Checked Then
   'add title2 to listbox
Else If radiobutton3.Checked Then
   'add title3 to listbox
End If

User is offlineProfile CardPM
+Quote Post

bflyroses
RE: Radio Buttons And Listbox
13 Mar, 2007 - 01:57 PM
Post #3

New D.I.C Head
*

Joined: 13 Mar, 2007
Posts: 3


My Contributions
QUOTE(jayman9 @ 13 Mar, 2007 - 02:32 PM) *

You can do that by using the Checked Property to determine which radiobutton is selected.

To give you an idea of what I mean:
CODE

If radiobutton1.Checked Then
   'add title to listbox
Else If radiobutton2.Checked Then
   'add title2 to listbox
Else If radiobutton3.Checked Then
   'add title3 to listbox
End If




I have that done for prices to go to the label based on number of tickets wanted but still am stuck on stupid on how to place the prices and movie names in the listbox here is my code for the radio buttons and label

Private Sub radOne_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radOne.CheckedChanged, radTwo.CheckedChanged, _
radThree.CheckedChanged, _
radFour.CheckedChanged, _
radFive.CheckedChanged, _
radSix.CheckedChanged



decSubtotal = Reg_Price * City_Tax

decTotal = decSubTotal + Reg_Price
decSubDisTotal = Discount_Price * City_Tax

decDisTotal = decSubDisTotal + Discount_Price

If (radOne.Checked) Then
lblCalculate.Text = decTotal.ToString("c")
ElseIf (chkDiscount.Checked) Then
lblCalculate.Text = decDisTotal.ToString("c")

End If
If (radTwo.Checked) Then
lblCalculate.Text = (decTotal * 2).ToString("c")
ElseIf (chkDiscount.Checked) Then
lblCalculate.Text = (decDisTotal * 2).ToString("c")
End If
If (radThree.Checked) Then
lblCalculate.Text = (decTotal * 3).ToString("c")
ElseIf (chkDiscount.Checked) Then
lblCalculate.Text = (decDisTotal * 3).ToString("c")

End If
If (radFour.Checked) Then
lblCalculate.Text = (decTotal * 4).ToString("c")
ElseIf (chkDiscount.Checked) Then
lblCalculate.Text = (decDisTotal * 4).ToString("c")

End If
If (radFive.Checked) Then
lblCalculate.Text = (decTotal * 5).ToString("c")
ElseIf (chkDiscount.Checked) Then
lblCalculate.Text = (decDisTotal * 5).ToString("c")

End If
If (radSix.Checked) Then
lblCalculate.Text = (decTotal * 6).ToString("c")
ElseIf (chkDiscount.Checked) Then
lblCalculate.Text = (decDisTotal * 6).ToString("c")

End If

I have declared global constants so they will function in all my controls

I am really so confused right now and its probably something very easily done but can't untwist it
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Radio Buttons And Listbox
13 Mar, 2007 - 08:55 PM
Post #4

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,984



Thanked: 44 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
Well to add items to a listbox you use the Items.Add method.
So just replace AddSomething with whatever it is you want to add to the listbox.
CODE

Me.Listbox1.Items.Add(AddSomething)

User is offlineProfile CardPM
+Quote Post

bflyroses
RE: Radio Buttons And Listbox
14 Mar, 2007 - 06:53 AM
Post #5

New D.I.C Head
*

Joined: 13 Mar, 2007
Posts: 3


My Contributions
QUOTE(jayman9 @ 13 Mar, 2007 - 09:55 PM) *

Well to add items to a listbox you use the Items.Add method.
So just replace AddSomething with whatever it is you want to add to the listbox.
CODE

Me.Listbox1.Items.Add(AddSomething)






I guess I am not communicating well enough its more complicated then just adding a item to the listbox that I can do but thanks anyway
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 03:14PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month