8 Replies - 3840 Views - Last Post: 06 December 2009 - 11:49 PM Rate Topic: -----

#1 chepab04  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 02-November 09

Input box and Listbox

Post icon  Posted 06 December 2009 - 02:37 PM

Public Class frmDvds
Const NEW_RELEASE As Decimal = 3.75
Const OTHER_MOVIES As Decimal = 1.75
Dim strChildMovie As String = "UP" 'New Release movie
Dim strActionMovie As String = "Taken" 'Other movie
Dim strComedyMovie As String = "Yes Man" 'New Release moive
Dim strHorrorMovie As String = "Chucky" ' Other moive
Dim strDramaMovie As String = "My Sisters Keeper" 'New Release moive



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

'Close the application

Me.Close()


End Sub

Private Sub cboTypeofMovie_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTypeofMovie.SelectedIndexChanged




'Display The movie that you like in other combo box
If cboTypeofMovie.SelectedItem = "Children" Then
cboChooseMovies.Items.Add(strChildMovie)
ElseIf cboTypeofMovie.SelectedItem = "Action" Then
cboChooseMovies.Items.Add(strActionMovie)
ElseIf cboTypeofMovie.SelectedItem = "Comedy" Then
cboChooseMovies.Items.Add(strComedyMovie)
ElseIf cboTypeofMovie.SelectedItem = "Horror" Then
cboChooseMovies.Items.Add(strHorrorMovie)
ElseIf cboTypeofMovie.SelectedItem = "Drama" Then
cboChooseMovies.Items.Add(strDramaMovie)
End If


End Sub

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

'does not exist no more



End Sub

Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click


'Display a messagebox if no movie is selected
If cboTypeofMovie.SelectedIndex = -1 Then
'Display this message
MessageBox.Show(" No Movie Has Been Selected! ", "Please Select A Movie")
End If


'display the selection in the label
lblMovieChoice.Text = cboChooseMovies.Text


End Sub

Private Sub frmDvds_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click

'Exit the application
Me.Close()

End Sub

Private Sub mnuReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuReset.Click

'this procedure clears selections in the combo boxes
cboTypeofMovie.SelectedIndex = -1
cboTypeofMovie.Text = String.Empty
cboChooseMovies.SelectedIndex = -1
cboChooseMovies.Text = String.Empty


'Reset the label
lblMovieChoice.Text = String.Empty

End Sub

Private Sub btnRent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRent.Click


Dim strInput As String 'To get the users input
Dim decTotal As Decimal 'Use as the accumulator
Dim intCount As Integer 'Loop Counter


'Display a messagebox if
'No movie is selected for rent
If cboTypeofMovie.SelectedIndex = -1 Then
'Display this message
MessageBox.Show(" No Movie Has Been Selected! ", "Please Select A Movie")
End If


'Store the correct starting value in the counter
'and the accumulator.
intCount = 1
decTotal = 0


'The following loop checks if the credit card
'or debit card number is 16 numbers
Do Until intCount = 16
If intCount <> 16 Then
strInput = InputBox(" Enter Your 16 Debit or Credit Card Number " & _
intCount.ToString(), "Debit or Credit Card Number Needed")

ElseIf intCount = 16 & strChildMovie Then
decTotal = CDec(NEW_RELEASE)
End If
Loop

'Display the total in the list box.
lstDisplay.Items.Add(NEW_RELEASE)
[color=#CC0000]


End Sub
End Class


NEED HELP ON THE HIGHLIGHTED PART
What i want is for the user to enter a 16 numeric number if it is 16 display the total of the movie
that got selected

Is This A Good Question/Topic? 0
  • +

Replies To: Input box and Listbox

#2 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: Input box and Listbox

Posted 06 December 2009 - 02:50 PM

something like:
Do
  strInput = InputBox(" Enter Your 16 Debit or Credit Card Number ")
Loop While strInput.Length <> 16


Was This Post Helpful? 0
  • +
  • -

#3 chepab04  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 02-November 09

Re: Input box and Listbox

Posted 06 December 2009 - 03:31 PM

View Postmark.bottomley, on 6 Dec, 2009 - 01:50 PM, said:

something like:
Do
  strInput = InputBox(" Enter Your 16 Debit or Credit Card Number ")
Loop While strInput.Length <> 16





Now to display the price of the selected movie in a listbox sorry i just can't figure it out ahhhh!! jaja
Was This Post Helpful? 0
  • +
  • -

#4 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: Input box and Listbox

Posted 06 December 2009 - 04:51 PM

cboChooseMovies.SelectedItem should get you the contents of the combobox.
Was This Post Helpful? 0
  • +
  • -

#5 chepab04  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 02-November 09

Re: Input box and Listbox

Posted 06 December 2009 - 05:51 PM

View Postmark.bottomley, on 6 Dec, 2009 - 03:51 PM, said:

cboChooseMovies.SelectedItem should get you the contents of the combobox.



Like using if and else? or select cases? so that I can display on a listbox a total?

if movie "up" is selected then
diplay the price for up which is a new release = 3.75 in a listbox like
"Your total is $3.75"
and if movie "taken" is selected which is an other movie then
display the price for "taken" is 1.75 dollar


how would i do that ?
Was This Post Helpful? 0
  • +
  • -

#6 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: Input box and Listbox

Posted 06 December 2009 - 06:12 PM

lstDisplay.Items.Add("Your total is $3.75")
should do what I think you want inside of the If/Else/End If
Was This Post Helpful? 0
  • +
  • -

#7 chepab04  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 02-November 09

Re: Input box and Listbox

Posted 06 December 2009 - 10:23 PM

View Postmark.bottomley, on 6 Dec, 2009 - 05:12 PM, said:

lstDisplay.Items.Add("Your total is $3.75")
should do what I think you want inside of the If/Else/End If


What im thinking of doing is let the user type in a 16 numeric number of
the credit card or debit yet if not numeric or 16 numbers show a message box
saying"Must be numeric and 16 numbers"


Do
strInput = InputBox(" Enter Your 16 Debit or Credit Card Number ")
Loop While strInput.Length <> 16


If it is 16 numbers and numeric
do the ..

If cboChooseMovies.SelectedItem = strChildMovie Then
lstDisplay.Items.Add("Your total is $3.75")
ElseIf cboChooseMovies.SelectedItem = strActionMovie Then
lstDisplay.Items.Add("Your total is $1.75")
ElseIf cboChooseMovies.SelectedItem = strComedyMovie Then
cboChooseMovies.Items.Add("Your total is $3.75")

ect..
would this function correctly?/??


Thanks for the help appriciate it alot
Was This Post Helpful? 0
  • +
  • -

#8 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: Input box and Listbox

Posted 06 December 2009 - 10:45 PM

looks about right - you can use a Mask (one of the textbox properties) to make them only able to enter digits. Normally, for that many ElseIf's, you would use a Select Case.
Was This Post Helpful? 0
  • +
  • -

#9 chepab04  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 02-November 09

Re: Input box and Listbox

Posted 06 December 2009 - 11:49 PM

View Postmark.bottomley, on 6 Dec, 2009 - 09:45 PM, said:

looks about right - you can use a Mask (one of the textbox properties) to make them only able to enter digits. Normally, for that many ElseIf's, you would use a Select Case.



Don't know what you mean by Mask but its cause im doing a project and its like for extra credit im almost done with it i just needed to use the isnumeric like the professor gave me a list of what he wants us to put in the program and he wants use to use listboxes and inputboxes and use some kind of error catching - exception handling or input validation im guessing that like the isnumeric function but thats all i need like it has to catch an error in the inputbox if it is not numeric and well i don't know how to do that im kinda new on this vb.net stuff jaja but hey im trying who doesn't want extra credit.

thanks all i need is to first catch the error if its not 16 numbers on the inputbox that im using and display an error then if it is display the total of the movie like im guessing it is done by using if and elses and then display it on the listbox thats what reallly all i need for completing my project and im like going crazy can't figure it out jaja
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1