Visual Basic 6.0 Programming learning

Visual Basic 6.0 Programming learning

Share

Making simple software programs &Teaching the world for free.

28/05/2015

The following program uses the Hypotenuse funtion.

Object:

frm4_3_4>caption>Right Triangle.
lblSideOne>Caption>length of one side.
txtSideOne>Text>(blank).
lblSideTwo>caption>Length of other side.
txtSideTwo>text>(blank).
cmdCalculate>caption>Calculate Hypotenuse.
lblHelp>caption>Length of Hypotenuse.
picHyp.

codin

private sub cmdCalculate_Click()
Dim a As Single, b As Single
'Calculate Length of the hypotenuse of a right triangle
a = Val(txtSideOne.Text)
b = Val(txtSideTwo.Text)
picHyp.Cls
picHyp.Print Hypotenuse(a, b)
End Sub

Private Function Hypotenuse(a As Single, b As Single) As Single
'Calculate the hypotenuse of a right triangle
'having sides of lengths a and b
Hypotenuse = sqr(a ^ 2 + b ^ 2)
End Function

[Run, type 3 and 4 into the boxes, and then click the command button]

Old School Days.......(a + b) =?

11/04/2015

The following program requests a color(blue or red)&a mode(steady or flashing)as input and display the weather forecast.the program contains a select Case block with a string expression as the selector.

steady blue, clear view.
flashing blue, clouds due.
steady red, rain ahead.
flashing red, snow instead.

frmWeather>caption>Weather Beacon.
lblColor>caption>color of the light.
txtColor>text>(blank).
lblMode>caption>Mode (S or F).
txtMode>text>(blank).
cmdInterpret>caption>Interpret Beacon.
picForecast.

codin.

private sub cmdInterpret_click().
dim color as string, mode as string.
'Interpret a weather beacon.
picForecast.Cls.
color=txtColor.text.
mode=txtMode.text.
select Case UCase(mode)&UCase(color).
Case "SBlue".
picForecast.print "CLEAR VIEW"
Case "FBlue"
picForecast.print "CLOUDS DUE"
Case "SRed".
picForecast.print "RAIN AHEAD"
Case "FRED"
picForecast.print "SNOW AHEAD"
End Select
End Sub

[run, type red and S into the text boxes, and press the command button.]

Want your school to be the top-listed School/college in Lusaka?
Click here to claim your Sponsored Listing.

Category

Telephone

Address


Libala South
Lusaka
LUSAKA