ListBox items question


Public Class Form1 Private strMovie(9) As String Private intMatinee(9) As Integer Private intEvening(9) As Integer Private intCounter As Integer = 0 Private Sub btnAddMovie_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddMovie.Click strMovie(intCounter) = InputBox("Enter the movie name") intMatinee(intCounter) = InputBox("Enter the number of matinee tickets sold") intEvening(intCounter) = InputBox("Enter the number of evening tickets sold") lstMovies.Items.Add(strMovie(intCounter)) intCounter += 1 End Sub Private Sub btnShowSelected_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowSelected.Click Dim strMovie As String = "" Dim decTicketSales As Decimal = 0 strMovie = lstMovies.SelectedItem decTicketSales = intMatinee(lstMovies.SelectedIndex) * 6 + _ intEvening(lstMovies.SelectedIndex) * 8 lblOutput.Text = "The sales for movie " & strMovie & _ " is " & decTicketSales.ToString("c") End Sub Private Sub btnTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTotal.Click Dim decTicketSales As Decimal Dim strMovie As String = "" strMovie = lstMovies.SelectedItem If radMatinee.Checked Then decTicketSales = intMatinee(lstMovies.SelectedIndex) * 6 Else : decTicketSales = intEvening(lstMovies.SelectedIndex) * 8 End If lblOutput.Text = "The total ticket sales for movie " & strMovie & _ " are " & decTicketSales.ToString("c") End Sub Private Sub btnHighest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHighest.Click End Sub End Class

This is a final project for my VB05 class. We add movies to the list box then the number of matinee and evening tickets sold per movie. Got that part down. Got the option of choosing the total tickets sales per movie for matinee or evening. Also have that done. BtnHighest and BtnLowest are the only things causing me a problem. They select the highest or lowest ticket sales for the day with either matinee or evening selected.

The program runs fine with the exception of those 2 buttons. Any suggestions as to how to get those to work are greatly appreciated. If you can suggest anyway to clean up my code a little also, that would be great. Still a beginner at this.

Posted On: Monday 24th of December 2012 01:09:21 AM Total Views:  269
View Complete with Replies

RELATED TOPICS OF Visual Basic PROGRAMMING LANGUAGE




Re: Randomly call an item from any of 5 listboxes.

Good afternoon, I used to have a program where I press a button and it would randomly pick 1 item from 1 listbox and then take it out of the listbox and put it in another listbox. Now I am working on a new program where I randomly call items, but instead of 1 listbox, it has 5 listboxes, and what I would like to do is have it so if there is atleast 1 item in that listbox it is possible to call an item from it. This is the code I used with just 1 listbox. VB Code: Dim lIndex As Long If List1.ListCount Then lIndex = Int(Rnd * List1.ListCount) Label1.Caption = List1.List(lIndex) List2.AddItem List1.List(lIndex) List1.RemoveItem lIndex End If List1 was the listbox that had all the numbers, now I would like to have 5. The reason is I am dividing them the items up into categories. So there is no list1, there is list6, list7, list8, list9, list10. Can anyone help me out.
VIEWS ON THIS POST

92

Posted on:

Wednesday 24th October 2012
View Replies!

Re: How to put numbers in a listbox in sorted asending order

When I load a ListBox control with numbers (Sorted=True) they come out like this: 1 10 11 12 13 . . 19 2 20 21 . . 29 3 30 31 ' ' etc I need the number to be like this: 1 2 3 4 . . . 10 11 12 13 . . . etc I would like to use real number and not text numbers that I have to pad with leading zeros.
VIEWS ON THIS POST

125

Posted on:

Wednesday 24th October 2012
View Replies!

Getting strange symbols in listbox

when i load a file into a list box i get a strange character. The character looks like this:  It shows that and then the first thing in my file, so if my file read "Nellie" the list box would show "Nellie". I have tried deleting things on front of the word, tried clearing the listboxes, tried pretty much everything i could think of. Here is my code so you can see if i have done anything wrong: Code: Private Sub cmdLoad_Click() Dim strname As String Dim intfilenbr As Integer Dim strfirst As String Dim strlast As String Dim stremail As String Dim strpass As String lstFirst.Clear lstLast.Clear lstEmail.Clear lstPass.Clear intfilenbr = FreeFile strname = App.Path & "\names.csv" Open strname For Input As #intfilenbr Do Until EOF(intfilenbr) Input #intfilenbr, strfirst, strlast, stremail, strpass lstFirst.AddItem strfirst lstLast.AddItem strlast lstEmail.AddItem stremail lstPass.AddItem strpass Loop Close #intfilenbr End Sub Also this character only shows in the first listbox and none of the other ones. Thank you to anyone that can help.
VIEWS ON THIS POST

147

Posted on:

Wednesday 24th October 2012
View Replies!

Re: webbrowser to listbox

hello again, how can i put every text in web browser in a listbox\t
VIEWS ON THIS POST

119

Posted on:

Wednesday 24th October 2012
View Replies!

Try Catch Not Stopping Execution of code

, I have been experiencing a problem with one of my Try Catch blocks. I have tried everything I can think of and have had no luck finding any help through Google or other methods. Specifically, I have a block of code that inserts data into a db using a stored procedure. There is a problem within the codegetting one of the parameters to the SP. I know what the problem is and how to fix it. My issue is that the Try Catch should be stopping any furtherexecution of code once it catches the error. I have verified that the error is being caught and that it sends the exception to my label used for error reprorting. However, instead of stopping future execution and displaying the error it rolls over the label assignment and continues to the next piece of code in the calling procedure. In essence, it is as if there is no error occuring at all. To give apoint of reference, Icall a sub-routine from a button click event. Within the sub-routine I have my Try Catch block with the SP code. I am NOT using Try Catch Finally. It is simply Try the SP Catch ex as Exception and End Try. Does anyone have an idea as to how this can happen
VIEWS ON THIS POST

102

Posted on:

Friday 2nd November 2012
View Replies!

ArrayList Contains a What?

: I know that you can check to see if an array list contains an item by doing the following: If colArrayListOne.Contains("hello") Then \tresponse.write("hello there") End If But, how can you check to see how many times the same item exists in the array list\t Sort of like contain the repetition...
VIEWS ON THIS POST

76

Posted on:

Friday 2nd November 2012
View Replies!

Constructor

, I having problems in accessing the constructor to open connection. The connection is stored in a Data layer class. It gives me an error in the class when I run the program; and points to the connectionstring property, saying that NEW keyword should be used or instance . the connectionstring is defined in the web.config file Imports System Imports System.Data Imports System.Data.SqlClient Imports System.Configuration.ConfigurationManager Imports System.Configuration Public Class DataLayer \t Private Con_String As String \t Private sql As New SqlConnection Public Sub New() Dim strConnString As String = ConfigurationManager.ConnectionStrings("Arsenal").ConnectionString sql.ConnectionString = strConnString sql.Open() End Sub End Class TIA
VIEWS ON THIS POST

84

Posted on:

Wednesday 7th November 2012
View Replies!

How to copy Datagrid contents to Flexgrid ?

My application uses several datagrids. Looking on the internet, i found an excellent free(!) printing module on www.adit.co.uk Unfortunately this module only works with the plain Flexgrid (and not with Datagrid or Hierarchical Flexgrid) I'm thinking about placing an invisible Flexgrid on my form, copy the Datagrids contents to this flexgrid, and use this as print source. My question: - How do i copy the contents from the Datagrid to the Flexgrid I tried using MSHFlexgrid (which uses ADO) instead of Flexgrid (that uses DAO), but unfortunately that doesn't work .....
VIEWS ON THIS POST

125

Posted on:

Wednesday 7th November 2012
View Replies!

Re: no .asp

Is the Microsoft IIS instaled on the server \t To run correctly ASP pages on the server, Microsoft Internet Information Server must to be installed on the server. By "Jeremy" escribi en el mensaje news:3f25a73b$1_2@mk-nntp-2.news.uk.tiscali.com... > I am ...
VIEWS ON THIS POST

80

Posted on:

Saturday 10th November 2012
View Replies!

Mouse Button 2

Hi again, I am trying to use the right mouse button to initiate a procedure. I am using the following code: Private Sub txtCustomerNo_MouseDown(button As Integer, shift As Integer, X As Single, Y As Single) If button = 2 Then ...
VIEWS ON THIS POST

136

Posted on:

Saturday 10th November 2012
View Replies!

ignore this test - sent 5:36 AM 10/6/07

. Test....
VIEWS ON THIS POST

151

Posted on:

Sunday 11th November 2012
View Replies!

Does anyone know if there are still VB 6 jobs out there?

especially any jobs in london or SE England. if not how easy is it to go from vb6 to vb .net I'm at a crossroads many
VIEWS ON THIS POST

169

Posted on:

Sunday 11th November 2012
View Replies!

Comparing number values without "If" statements.

, I'm currently writing a VB project involving comparison operators. The goal is to determine whether or not, the inputted double values are equal to/greater than/less than to one another. The logical way of doing this in my mind was to use an "if" statement; however, I am told I cannot use an "if" for this particular project. Is there any other method of comparing 2 numbers from two separate text boxes and determining if >, = ,
VIEWS ON THIS POST

173

Posted on:

Sunday 11th November 2012
View Replies!

Login for a password form...multiple users

I am a beginner and below I have code for a long in form. My goal is for the form to read a file of a list of users and thier passwords ....compare the text box inputs to the ...
VIEWS ON THIS POST

147

Posted on:

Tuesday 20th November 2012
View Replies!

splashscreen

I have a strange problem. I use a splashscreen for my program. In the startform, I use the code: Private Sub Form_Load() frmSplash.Show Starttijd = Timer Do While Timer - Starttijd < 2 DoEvents Loop Unload frmSplash Ens Sub ...
VIEWS ON THIS POST

154

Posted on:

Tuesday 20th November 2012
View Replies!

Re: Mouse wheel, XP, and VB5

> Why doesn't my mouse wheel work in the code windows in VB5 under XP > I can scroll the properties and project windows using the wheel, but > not the actual code windows (XP). Everything works fine using Windows ...
VIEWS ON THIS POST

107

Posted on:

Tuesday 20th November 2012
View Replies!

Wheres The File Path?

I wrote an app thats alot like a text editor. It produces files of a User Defined type. I want the user to be able to dble click on a saved file that was made by my program and have ...
VIEWS ON THIS POST

210

Posted on:

Tuesday 20th November 2012
View Replies!

MS will remove VB6 and replace with VB.Net

Guys, I'am a newbie in VB . I heard from a friend of mine that Microsoft will remove VB6 in 2008 . Is it true ....
VIEWS ON THIS POST

161

Posted on:

Monday 26th November 2012
View Replies!

how to plot graphs using mscharts and using file as input?

hi, we are working on a project where we are required to plot graphs using mscharts.we would collect the data in a text file and plot a 2d ,line graph using mscharts. can u plz help us in that
VIEWS ON THIS POST

272

Posted on:

Wednesday 28th November 2012
View Replies!

decision tree/work process?

Hi . I am new here and a real NOOB. I am trying to add a function to a spread sheet so that when you click a button, a box will open and ask a series of questions, adn depending on your ansers, take you to different results. for example, It could say "Is the sky blue Yes or No" answer No. Next question, "is it cloudy Yes or No", etc. It is to help co-workers know what decisions to make under certain defined paramaters. I hope I have explained this well. I have tried searching and have come up empty.
VIEWS ON THIS POST

125

Posted on:

Wednesday 28th November 2012
View Replies!

Format Data Series patterns in Excel chart from VB

Hi , This might be something simple, I have exported a graph from my MSFlex grid in VB6 to Excel, everything works fine. I just need to format the patterns under the data series to a different line and marker foreground color, style, and etc. Any suggestions\t
VIEWS ON THIS POST

122

Posted on:

Thursday 29th November 2012
View Replies!

how to read a word document using a textbox in vb?

please i need help with the correct code. i am using vb8 and i can't find out the way to solve my problem.
VIEWS ON THIS POST

129

Posted on:

Friday 30th November 2012
View Replies!

EvenOdd Program

I have to create an application that displays all the even numbers and all the odd numbers between two numbers entered by th user. For instance between 6 and 25 or between 10 and 3. I'm at a total lose as to how to code this. Can anyone PLEASE PLEASE get me on the right track Here is what I have so far plus I am attaching a picture of the application. Option Explicit On Option Strict On Imports System.Globalization Public Class MainForm Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click Me.Close() End Sub Private Sub clearButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles clearButton.Click ' clears the numbers and setthe focus firstNumberTextBox.Clear() secondNumberTextBox.Clear() oddNumbersLabel.Text = ("") evenNumbersLabel.Text = ("") firstNumberTextBox.Focus() End Sub Private Sub displayButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles displayButton.Click ' displays all the odd and even numbers between ' two integers entered by the user Dim firstNumber As Integer Dim secondNumber As Integer Dim isConverted1 As Boolean Dim isConverted2 As Boolean isConverted1 = Integer.TryParse(firstNumberTextBox.Text, firstNumber) isConverted2 = Integer.TryParse(secondNumberTextBox.Text, secondNumber) oddNumbersLabel.Text = String.Empty For oddNumber As Integer = 1 To 1000000 Step 2 oddNumbersLabel.Text = oddNumbersLabel.Text & oddNumber + 2 & ControlChars.NewLine Next oddNumber evenNumbersLabel.Text = String.Empty For evenNumber As Integer = 2 To 1000000 Step 2 evenNumbersLabel.Text = evenNumbersLabel.Text & evenNumber + 2 & ControlChars.NewLine Next evenNumber End Sub End Class Attached File(s) EvenOdd_Project.bmp (752.28K) Number of downloads: 118
VIEWS ON THIS POST

76

Posted on:

Friday 30th November 2012
View Replies!