This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Showing posts with label control construct. Show all posts
Showing posts with label control construct. Show all posts

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

Fabonacci series,factorial of a number or prime number in visual basic.


Dim i, f, n As Integer
Dim a, b, c As Integer
Private Sub Cmdtable_Click()
n = Val(Text1.Text)
Me.Cls
For i = 1 To 10 Step 1
Me.Printi * n
Next i
End Sub

Private Sub CmdFabonaccii_Click()
Me.Cls
a = 0
b = 1
Me.Print a
Me.Print b
For j = 3 To 10 Step 1
c = a + b
a = b
b = c
Me.Print c
Next j
End Sub

Private Sub CmdFactorial_Click()
fact = 1
n = Val(Text1.Text)
i = 1
Do While (i<= n)
fact = fact * i
i = i + 1
Loop
MsgBox "the factorial is: " & fact
End Sub
Private Sub CmdPrime_click()
n = Val(Text1.Text)
Me.Cls
If n Mod 2 = 0 Then
Me.Print n & " is not prime"
Else
Me.Print n & " is prime"
End If
End Sub


Private Sub CmdExit_Click()
End
End Sub

 Output


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