Sunday, February 6, 2011

Making right angle triangle using asterisk w/ size

Hi guys! this is my right triangle with size 8. Here is the sample code of the image above. Hope this will help you.
Enjoy! and Happy coding!! :)


Private Sub Command1_Click()
For x = 1 To txtsize
    For y = 1 To x
    Label3.Caption = Label3.Caption & "*"
    Next
    Label3.Caption = Label3.Caption & vbCrLf
Next
End Sub

Moving your form upside down

Hi guys! this is the sample code of moving your form upside down. Hope this will help you. Enjoy!
Happy coding! :)


Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
Timer2.Enabled = True
End Sub

Private Sub Command3_Click()
Timer3.Enabled = True
End Sub

Private Sub Command4_Click()
Timer4.Enabled = True
End Sub

Private Sub Command5_Click()
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
End Sub

Private Sub Form_Load()
Timer1.Interval = 10
Timer2.Interval = 10
Timer3.Interval = 10
Timer4.Interval = 10
End Sub

Private Sub Timer1_Timer()
Me.Top = Me.Top - 10
End Sub

Private Sub Timer2_Timer()
Me.Top = Me.Top + 10
End Sub

Private Sub Timer3_Timer()
Me.Left = Me.Left + 10
End Sub

Private Sub Timer4_Timer()
Me.Left = Me.Left - 10
End Sub

Stopwatch

Hi guys! this is the sample code of the stopwatch that I made. Hope this will help you. Enjoy and Happy Coding! :)


Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

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

Private Sub Command3_Click()
sec.Caption = "00"
min.Caption = "00"
hour.Caption = "00"
End Sub

Private Sub Form_Load()
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
Dim h, m, s As Integer
sec.Caption = Val(sec.Caption) + 1
If Val(sec.Caption) < 10 Then
    sec.Caption = "0" & sec.Caption
End If
If Val(sec.Caption) = 60 Then
    min.Caption = Val(min.Caption) + 1
    sec.Caption = "00"
If Val(min.Caption) < 10 Then
    min.Caption = "0" & min.Caption
End If
   End If
If Val(min.Caption) = 60 Then
    hour.Caption = Val(hour.Caption) + 1
    min.Caption = "00"
If Val(hour.Caption) < 10 Then
    hour.Caption = "0" & hour.Caption
End If
   End If
End Sub

Moving texts using timer component

Hi guys! this is the sample code of the moving text using the timer component. hope this will help..
Happy coding! :)

Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Form_Load()
Label1.Left = 0
Label1.Top = 0
Timer1.Interval = 10
End Sub

Private Sub Timer1_Timer()
If Label1.Top = 0 Then
    Label1.Left = Label1.Left + 10
End If
If Label1.Left = 5000 Then
    Label1.Top = Label1.Top + 10
End If
If Label1.Top = 5000 Then
    Label1.Left = Label1.Left - 10
End If
If Label1.Left = 0 Then
    Label1.Top = Label1.Top - 10
End If
End Sub

Friday, February 4, 2011

How to generate 7 random letters

Hi everyone! this is a sample code on how to generate 7 random letters in one click.. hope this will help you!
happy coding!! :)


Private Sub Command1_Click()
Dim x, z As String
Label1.Caption = Empty
For y = 1 To 7
Randomize
x = Round(97 + 25 * Rnd())
z = UCase(Chr(x))
Label1.Caption = Label1.Caption + z
Next
End Sub

Welcome

Hi everyone! this is my new blog account. hope you enjoy viewing.. :)