Wednesday, 18 September 2013

GUI Program to demonstrate String Function

Private Sub Command1_Click()
Dim s As String
s = Text1.Text
Text2.Text = UCase(s)
Text3.Text = LCase(s)
Text4.Text = Len(s)
Text5.Text = StrReverse(s)
Text6.Text = Left(s, 5)
Text7.Text = Right(s, 5)
Text8.Text = Mid(s, 6, 5)
Text9.Text = String(10, "a")
Text10.Text = Replace(s, " ", "$$$$$")
End Sub

GUI Program to demonstrate Param array

Private Sub Command1_Click()
Dim a() As Integer
Call parray(100, 200, 300, 400, 100)
End Sub
Private Sub parray(ParamArray a())
Dim i As Integer
Dim sum As Integer
For i = 0 To UBound(a())
sum = sum + a(i)
Next i
Label1.Caption = "THe sum of array no's" & sum
End Sub

Private Sub Command2_Click()
Label1.Caption = " "
End Sub

Private Sub Command3_Click()
End
End Sub

GUI Program to demonstrate Dynamic array

Private Sub Command1_Click()
Dim a() As Integer
Dim i, n As Integer
Dim sum As Integer
sum = 0
n = InputBox("Enter the size of array")
Print "The size of array is" & n
ReDim a(n) As Integer
Print "The contents of array are"
For i = 1 To n
a(i) = InputBox("Enter array elements")
Print a(i)
sum = sum + a(i)
Next i
Print "The sum of array elements is" & sum
End Sub

Private Sub Command2_Click()
End
End Sub

GUI Program to demonstrate Scroll Control

Private Sub Form_Load()
Print "font size demo"
End Sub

Private Sub HScroll1_Change()
Form1.BackColor = vbYello
End Sub

Private Sub HScroll2_Change()
Form1.FontSize = "20"
Print "Font size demo"
Form1.FontSize = "30"
Print "font size demo"
End Sub

GUI Program to demonstrate Function array

Private Sub Command1_Click()
Dim v As Variant, x As Integer
v = Array(7, 5, 6, 9, 3, 0)
Print "Variant array value are:"
For x = LBound(v) To UBound(v)
Print v(x)
Next x
Print
v = Array("hello", "hai", "bye")
Print "Variant array value are:"
For x = LBound(v) To UBound(v)
Print v(x)
Next x
Print
v = Array("1.1", "2.2", "3.3", "4.4")
Print "Variant array value are:"
For x = LBound(v) To UBound(v)
Print v(x)
Next x
Print
End Sub

GUI Program to Validate User name and password

Private Sub Command1_Click()
If Text1.Text = "student" And Text2.Text = "dept123" Then
MsgBox "valid username and password", , "login"
Me.Hide
Else
MsgBox "invalid password,try again!", , "login"
End If
End Sub

Private Sub Command2_Click()
Me.Hide
End Sub

GUI Program to Demonstrate Timer control

Public mintcount As Integer
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
mintcount = mintcount + 1
Label1.Caption = "timer count is:" & mintcount
End Sub