Wednesday, March 26, 2014

Another VB6 Exercise for 1st. year Mechatronics Dept. students

Exercise: Write a VB6 Program to Calculate the Areas shown on the following Form according to the Option selected along with Unit of measurement. Three Command Buttons are to be used as illustrated below:
Solution:
Private Sub Command1_Click()
Dim x As Single
Dim z As Single
Dim r As Single
Dim y1 As Single
Dim y2 As Single
Dim y3 As Single

If Option1.Value = True Then
'Square
x = Val(Text1.Text): y1 = x ^ 2: Label4.Caption = Label4.Caption & " Square  =": Text4.Text = y1
Else
If Option2.Value = True Then
'Rectangle
x = Val(Text2.Text): z = Val(Text5.Text): Label4.Caption = Label4.Caption & " Rectangle  =": y2 = x * z: Text4.Text = y2
Else
If Option3.Value = True Then
'circle
r = Val(Text3.Text): y3 = r ^ 2 * (22 / 7): Label4.Caption = Label4.Caption & " Circle  =": Text4.Text = y3
End If
End If
End If
Label6.Caption = Text6.Text
Label7.Caption = "2"

End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Label4.Caption = "Area of "
Label6.Caption = ""
Label7.Caption = ""

End Sub

Private Sub Command3_Click()
End
End Sub

A VB6 Exercise For 1st. year student of Mechatronics Dept.

Exercise:Write a VB6 Program to Calculate Average of 5 input values when "average" key is pressed with the appearance of an Image named "Aver.jpg" as shown below, there is another Button key "RESET" that when pressed resets all values and makes image invisible!

Solution:
Dim Average As Single
Private Sub Command1_Click()
Average = Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text)
Average = Average / 5
Label1.Caption = Label1.Caption & Average
Image1.Visible = True
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Label1.Caption = ""
Image1.Visible = False

End Sub

Monday, March 17, 2014

An Excercise to be Solved by students!

Exercise: Write Matlab script to verify that the Model Output is Valid?

Sunday, March 09, 2014

My Complete Matlab Lectures gathered in One 12 Chapters-Text Book !

Here is My Complete Matlab Lectures containing 12 Chapters gathered in One Text Book..
You may Download it from either one of the the following Links below!
https://archive.org/details/IntroductionToMatlabForTechnicalEngineeringStudents2014 http://www.4shared.com/office/VoWpIEpKba/Introduction_To_Matlab_For_Tec.html
Download Link(1)    Download Link(2)

Saturday, March 01, 2014

Unsolved Matlab-GUI Exercise 4 students!

Exercise : For the the following Matlab GUI design, Write the necessary script code to Plot sin and cos (Ɵ), using push buttons "Plot Curves!", and "Reset entries" to Clear entries.

(For 2nd. Mechatronics class ONLY!)