PDA

View Full Version : More Help: Visual Basic Programming



Jeff
11-29-2006, 11:55 PM
Someone please help me! I am not used to Visual Basic



Part I
Purpose: To learn about the VB. Net IDE and write a simple program
Read the handouts and two example programs we have done in the lab.
Create a solution named Hello.sln in VB. Net on your disk that does the following:

The Form is to have its text property - your last name Hello Application (ex. Li's Hello Application)
The Form has the following controls from the Toolbox:
a Label
name: lblOut
text: blank (no characters)
a Textbox

name: txtMessage
text: blank (no characters)
a Button

name: btnShow
text: Show Message

In user interface design view, double-click btnShow (Show Message) button to generate btnShow_Click event
Write the code in the btnShow_Click event to display in lblOut whatever was typed in txtMessage (Hint: you only need 1 line of code using the text properties)
Remember, to save what you have done, you need to quit Visual Studio .Net, find the folder where you created your VB solution and copy that solution folder to your floppy disk or zip it.

Part IIPurpose: To learn more about programming by creating and running a program that:
Uses variables
Uses assignment statements
Uses If ... Then.. Else statements

Read My Math (http://www.apsu.edu/emmonsc/1005/notes/CSCI1005MyMathVB.htm) and Fun with Math (http://www.apsu.edu/emmonsc/1005/notes/CSCI1005FunwithMathVB.htm) example.
Create a program in Visual Basic in Visual Studio.Net that is named MathGame:
MathGame should have the following controls:

Control Name Range numeric up-down boxes nudNum1 0 ~ 20 numeric up-down boxes nudNum2 0 ~ 20Control Name Text at Design Time label lblOperation blank(no text) label lblEqual = label lblMessage blank (no text) textbox txtAnswer blank (no text) button btnClear Clear button btnAdd Add button btnMultiply Multiply
http://www.apsu.edu/emmonsc/1005/hw/1005as1.jpg
MathGame will have a click event for each button:


btnClear_Click
Clear the sign in lblOperation, the answer in txtAnswer, and message in lblMessage
btnAdd_Click

Display a + sign in lblOperation
Check to see if an answer has been entered in txtAnswer. If not use a message box to display an error message and Exit Sub
Check to see if the answer entered in txtAnswer is correct based on the two numbers being added. If so Display "Correct" in lblMessage. If incorrect answer Display "Incorrect" in lblMessage
btnMultiply_Click

Display an * sign in lblOperation
Check to see if an answer has been entered in txtAnswer. If not use a message box to display an error message and Exit Sub
Check to see if the answer entered in txtAnswer is correct based on the two numbers being multiplied. If so Display "Correct" in lblMessage. If incorrect answer Display "Incorrect" in lblMessage
Comments (follow a single quotation mark):

'Your name
'Purpose of the program
'CSCI 1005
'In each event explain what your code is doing

spikey_richie
11-30-2006, 12:09 AM
First of all, do you have the SDK?

Second, which parts are you needing help with?

I've not programmed in .Net, but I've been programming in VB since about 1998 :icon_cool:

Jeff
11-30-2006, 12:30 AM
Ha, what is the SDK? I don't even know where to begin.

NeoGen
11-30-2006, 12:40 AM
Be cool Jeff, it's easy... :)

I think what Spikey_richie meant was the IDE, do you already have Visual Studio installed?

Anyways... open Visual Studio, select the options to create a new Visual Basic Windows Application, and from there you have the empty form, and a toolbar on the left with buttons and controls that you can drag and drop onto the form...

From there on... double click the form, or the controls for Visual Studio to create for you the stubs where you will fill with your code. And from there you can also create your own functions and subs...

spikey_richie
11-30-2006, 12:55 AM
Sorry SDK = compiler/IDE

If you don't have it already, I seem to remember M$ doing a free cut-down environment.

Good dev forums I use:

forums.devx.com

www.xtremevbtalk.com

Jeff
11-30-2006, 12:57 AM
Alright, I just figured out the first part (didn't know there was a toolbox).

Now - Write the code in the btnShow_Click event to display in lblOut whatever was typed in txtMessage (Hint: you only need 1 line of code using the text properties)

NeoGen
11-30-2006, 01:02 AM
Drag a button from the toolbox on the left into your form, that button will be named "CommandButton1" I think. On the right side of the IDE you have the properties bar, click once on the button just to select it and you'll see all the properties of the button. Search for the name property and change it to "btnShow" as it is requested on your task.
Then double click the button and Visual Studio will create you the stub code for the click event. Inside the Sub that VS created you just have to add that one line of code... and your line of code is:

lblOut.text = txtMessage.text

(This will work provided that you already have on your form a textbox control with name "txtMessage" and a label control named "lblOut")

EDIT:
If you're working with Visual Studio 2003 I think that one line of code is...
lblOut.caption = txtMessage.text

There was a change on that property from VS2003 to VS2005/Express

Jeff
11-30-2006, 01:06 AM
Success!! THANK YOU!

Neogen, do you have MSN or AIM?

NeoGen
11-30-2006, 01:18 AM
MSN... how didn't I think of that before!!! We even spoke on it this afternoon... lol :)

Scooter
11-30-2006, 01:22 AM
i was thinking we have a nice new chat room ....that woulda worked too...lol

Nflight
11-30-2006, 01:35 AM
yes we do have a nice new flashchat room and there is no one in there but me at this present time!