Sunday, December 9, 2012

Timer Control and Formating option in visual Basic


Dim i As Long
Private Sub CmdCUt_Click()
Clipboard.SetText Txtnum1.SelText
Txtnum1.SelText = ""
CmdPaste.Enabled = True
End Sub

Private Sub CmdCopy_Click()
Clipboard.SetText Txtnum1.SelText
CmdPaste.Enabled = True
End Sub

Private Sub CmdPaste_Click()
Txtnum1.SelText = Clipboard.GetText
End Sub
Private Sub CmdSelect_Click()
Txtnum1.SelStart = 0
Txtnum1.SelLength = Len(Txtnum1.Text)
Txtnum1.SetFocus
End Sub
Private Sub Optfnm1_Click()
If Optfnm1.Value = True Then
Txtnum1.FontName = "Arial"
End If
End Sub
Private Sub Optfnm2_Click()
If Optfnm2.Value = True Then
Txtnum1.FontName = "Times New Roman"
End If
End Sub
Private Sub Optfnm3_Click()
If Optfnm3.Value = True Then
Txtnum1.FontName = "Calibri"
End If
End Sub
Private Sub Optfnm4_Click()
If Optfnm4.Value = True Then
Txtnum1.FontName = "Arial Black"
End If
End Sub

Private Sub Optfsz1_Click()
If Optfsz1.Value = True Then
Txtnum1.FontSize = 10
End If
End Sub
Private Sub Optfsz2_Click()
If Optfsz2.Value = True Then
Txtnum1.FontSize = 14
End If
End Sub
Private Sub Optfsz3_Click()
If Optfsz3.Value = True Then
Txtnum1.FontSize = 18
End If
End Sub
Private Sub Optfsz4_Click()
If Optfsz4.Value = True Then
Txtnum1.FontSize = 22
End If
End Sub
Private Sub Chkfs1_Click()
If Chkfs1.Value = vbChecked Then
Txtnum1.FontBold = True
Else
Txtnum1.FontBold = False
End If
End Sub
Private Sub Chkfs2_Click()
If Chkfs2.Value = vbChecked Then
Txtnum1.FontItalic = True
Else
Txtnum1.FontItalic = False
End If
End Sub

Private Sub Chkfs3_Click()
If Chkfs3.Value = vbChecked Then
Txtnum1.FontUnderline = True
Else
Txtnum1.FontUnderline = False
End If
End Sub
Private Sub Chkfs4_Click()
If Chkfs4.Value = vbChecked Then
Txtnum1.FontStrikethru = True
Else
Txtnum1.FontStrikethru = False
End If
End Sub
Private Sub Form_Load()
CmdPaste.Enabled = False
Txtnum1.FontItalic = True
Txtnum1.FontName = "Arial"
Txtnum1.FontSize = 14
Labeltitle.Caption = Now
i = 12460
End Sub
Private Sub HScroll1_Change()
Txtnum1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End Sub
Private Sub HScroll1_Scroll()
Txtnum1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End Sub

Private Sub HScroll2_Change()
Txtnum1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End Sub
Private Sub HScroll2_Scroll()
Txtnum1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End Sub

Private Sub HScroll3_Change()
Txtnum1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End Sub
Private Sub HScroll3_Scroll()
Txtnum1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End Sub
Private Sub VScroll1_Change()
Txtnum1.ForeColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)
End Sub
Private Sub VScroll1_Scroll()
Txtnum1.ForeColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)
End Sub
Private Sub VScroll2_Change()
Txtnum1.ForeColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)
End Sub
Private Sub VScroll2_Scroll()
Txtnum1.ForeColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)
End Sub
Private Sub VScroll3_Change()
Txtnum1.ForeColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)
End Sub
Private Sub VScroll3_Scroll()
Txtnum1.ForeColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)
End Sub
Private Sub Timer1_Timer()
Labeltitle.Caption = Now
i = i – 100
If i < -400 Then
i = 12460
End If
Labeltitle.Left = i
End Sub




 Output


Note:- Please set some property of your control like caption or id corresponding to your control