Visual Basic program help... please...

Deadline

Tank
Joined
Aug 19, 2003
Messages
1,836
Reaction score
1
Ok so I am in VB in college and my professor is a total jackass and half the class is failing... anyhow I need help with an assignment... I really need to get a good grade on this or im gonna be screwed. If anyone is willing to help, thank you, Im using 6.0 btw. here are his instructions...

Create a program that uses a variable to store an integer or long value (a number) when the user clicks a command button,and then displays the value back on the screen when the user clicks a different command button.

Here is how you can proceed:
Place a textbox on the screen. Lets call it txtInput.
Place a label on the screen. Call it lblDisplay.
Place two command buttons on the screen. Call them cmdStore and cmdDisplay.

In the general declarations section of your program (in addition to the description of the program and your name), define (declare) a variable that will hold the number value from the text box (txtInput).
Do this by using the Visual Basic reserved word Dim.

In the click event of the cmdStore button, write some VB code that will take the VALue of the textbox - val(txtInput.text) - and place it in the variable using the VAL function.

In the click event of the cmdDisplay button, write some VB code that will take the value stored in the variable and place that value in the caption property of the label - lblDisplay.Caption.


Thanks in advanced guys, if you want to help me and not just give me answers, IM me PLEASE!
 
I don't know VB, but there is a coding forum.

also, this seems very basic problem to me, I'm sure anyone can help you.

my advice would be to look at online tuts, and man, I know what you mean, my prof is bad too.
if your prof is anything like mine, do this: practice ALOT. that's what programming is all about.
no matter how much you read, you can't program unless you practice lots, really lots.
 
Yea I just need some help... but damn this guy is ridiculous... anyhow any help would be appreciated, at least to get me started. Then I can screw aaround and actually figure out what im doing.
 
I took VB in my freshman year of high school, and I really would help you, but I forgot everything. Argh. :(
 
How much do you know??

To declate an integer do this:

Code:
Dim MyVariable as Integer

Presumably you know how to create a form in VB with a textbox, label and buttons in it.

Once you've done that you need to put your code in the click events of your buttons.

If you need more help, ask.
 
Ok, so I'm not so good at teaching people, so I'll just punch out exactly what you need to do. I've never used the VAL command before, but from the looks of it, it shouldn't be hard to change what I've done to use the command like you're supposed to. I put it in a spoiler tag in case you didn't want to just blindly read the answers: -

Ok, so I'm assuming you already have the objects all laid out. Open up the code and in the declarations section write: -

Dim num as Integer

This sets a variable called 'num' so that we have somewhere to put the integer.

Ok, so now go back to the object screen and double click on the cmdStore button. This will automatically make a sub that will run every time the button is pressed. Inside the sub, write: -

num = txtInput.Text

This will erase what is currently stored in the 'num' variable and store whatever is in the txtInput textbox.

Go back to the object screen again, and this time double click on the cmdDisplay button. Inside the sub, write: -

lblDisplay.Caption = num

This will take whatever value is stored in num and place it in the caption of the lblDisplay label.

Hope that helps, let me know if you run into any problems.
 
Thanks much, i will work on my project later tonight after work, so ill get back to you on how it comes out.

Thanks again!
 
Back
Top