# Visual Basic 2008



## curiosity (May 14, 2009)

I cannot get the codes for the textboxes to work for this Rental Equipment. I am suppose to write a program that displays a table in a list box when an appropriate button is clicked and displays a bill in another list box based on the item number and time period chosen by a customer. The bill should include a $30.00 deposit. The form consists of two buttons, two listboxes and two textboxes with labels. One label says select 1, 2, or 3. The other says select H or F. I cannot get the textboxes to work. See attachment for code


----------



## Ent (Apr 11, 2009)

That code all looks pretty sound, but you haven't actually included anything about the txtboxes, instead having the bill hard-coded for Lawn mower. It is kind of tricky therefore to work out where your problem is. Since I'm guessing you are an IT student of some sort (And please don't take offence if you aren't) I want to help but cannot reasonbly write your code for you.


----------



## Mzlolita (Jun 14, 2009)

I am a student. I will state this immediately. I have written the entire code, but have one squiggly line that is stopping me from de-bugging. I cannot figure out what step I must have messed up on. Can you just help me to figure out what I did wrong. 

Visual Basic 2008

Thanks a million.


----------



## Ent (Apr 11, 2009)

Well done. The line that is giving you the primary problem is "select case" in "btnDisplayBill_Click", because you haven't told it what to select on. This works well enough:

```
Select Case TextBox1.Text + TextBox3.Text
```
Later you have used select case on textbox1, and presumably when it didn't work added a dim statement. You need to kill the dim, and make it select case textbox1.text; textbox1 is a control, not a number, but dimensioning a blank integer of the same name won't work.

Both of these would benefit from a case else statement.

At the bottom you've done fairly well, but forgot to do anything with the Duration variable after deciding what it is.

With those sorted your code runs, and appears to work. I suspect your real problem with this work is going to be how heavily it is hard coded (Especially if your teacher has the trying personality of asking for a small change at submission time (which is a good way to check they actually wrote the code). An array of names and prices would be particularly useful in improving it if possible, using val(textbox1.text) as the index. With a little work, such might even allow you to have a few items in the receipt, perform actual calculations, add stock, etc.

Incidentally You should also stretch Listbox2 down a bit, the reciept runs off the end.

Thanks for being so honest. There are many who aren't, and so fill post upon post with doubtful stories without getting any help. Good luck with your debugging.

Ent


----------



## Ent (Apr 11, 2009)

Don't forget, textbox1 is a small, white box on your form, with a flashing line AND a small piece of text or number. Don't try and calcuate with the box or see if the box is equal to 2. Use textbox1.text instead. That is the one concept you don't seem to have grasped in this piece.


----------



## DoubleHelix (Dec 10, 2004)

Did your instructor talk to you about object naming conventions. It's really bad form to name things "TextBox1". It makes your code very difficult to read and maintain.


----------



## Mzlolita (Jun 14, 2009)

Thanks a million. I figured that it was something minor that I had done. I just could not possibly 'think' any more. I had stared at that thing what seemed like forever.

I can't remember, but she may have talked about naming conventions. It is completely an online course. I have been begging the school for a lead to a tutor, with no response at all.

I will correct that as well, what you said made a lot of sense.

Bless you all for being so kind or quick with a response.  :up:


----------



## Mzlolita (Jun 14, 2009)

After much hard work, and listening to your wonderful suggestions, here is the finalized project:

Thanks a million...and then some!!!!!!!!!!!!!!!!!


----------



## Ent (Apr 11, 2009)

Great. I assume that means this thread is solved?


----------



## Mzlolita (Jun 14, 2009)

Yes, thank you. I am very, very happy!


----------

