Customize Font Dialog Box using ListBox,Checkbox,Frame in (VB6) Visual Basic 6.0
Visual Basic Customize Font Dialog Box is Identical to font dialog available with Microsoft Office.You can apply different font faces,Font Sizes,Font Styles and effects like Uppercase,Lowercase,Strike Through,Underline etc to the sample text.
We can design our own font dialog box using standard controls i.e Label,List Box,Checkbox,frame etc available in Visual Basic 6.0 (VB6).
Please subscribe:-)
Source Code:
Private Sub Form_Load()
Dim i As Integer
List1.AddItem "Times new roman"
List1.AddItem "Roman"
List1.AddItem "Stencil"
List1.AddItem "Calibri"
List1.AddItem "Batang"
List1.AddItem "Arial"
For i = 8 To 25 Step 2
List2.AddItem i
Next i
List3.AddItem "Regular"
List3.AddItem "Bold"
List3.AddItem "Italic"
List3.AddItem "Bold Italic"
End Sub
Private Sub List1_Click()
Label1.FontName = List1.Text
End Sub
Private Sub List2_Click()
Label1.FontSize = List2.Text
End Sub
Private Sub List3_Click()
If List3.Text = "Bold" Then
Label1.FontBold = True
ElseIf List3.Text = "Italic" Then
Label1.FontItalic = True
ElseIf List3.Text = "Bold Italic" Then
Label1.FontItalic = True
Label1.FontBold = True
ElseIf List3.Text = "Regular" Then
Label1.FontItalic = False
Label1.FontBold = False
Else
Label1.FontItalic = False
Label1.FontBold = False
End If
End Sub
Private Sub LowerCase_Click()
If LowerCase.Value = 1 Then
Label1.Caption = LCase(Label1.Caption)
Else
Label1.Caption = "Sample Text"
End If
End Sub
Private Sub Strike_Click()
If Strike.Value = 1 Then
Label1.FontStrikethru = True
Else
Label1.FontStrikethru = False
End If
End Sub
Private Sub Underline_Click()
If Underline.Value = 1 Then
Label1.FontUnderline = True
Else
Label1.FontUnderline = False
End If
End Sub
Private Sub UpperCase_Click()
If UpperCase.Value = 1 Then
Label1.Caption = UCase(Label1.Caption)
Else
Label1.Caption = "Sample Text"
End If
End Sub
Visual Basic Customize Font Dialog Box is Identical to font dialog available with Microsoft Office.You can apply different font faces,Font Sizes,Font Styles and effects like Uppercase,Lowercase,Strike Through,Underline etc to the sample text.
We can design our own font dialog box using standard controls i.e Label,List Box,Checkbox,frame etc available in Visual Basic 6.0 (VB6).
Please subscribe:-)
Source Code:
Private Sub Form_Load()
Dim i As Integer
List1.AddItem "Times new roman"
List1.AddItem "Roman"
List1.AddItem "Stencil"
List1.AddItem "Calibri"
List1.AddItem "Batang"
List1.AddItem "Arial"
For i = 8 To 25 Step 2
List2.AddItem i
Next i
List3.AddItem "Regular"
List3.AddItem "Bold"
List3.AddItem "Italic"
List3.AddItem "Bold Italic"
End Sub
Private Sub List1_Click()
Label1.FontName = List1.Text
End Sub
Private Sub List2_Click()
Label1.FontSize = List2.Text
End Sub
Private Sub List3_Click()
If List3.Text = "Bold" Then
Label1.FontBold = True
ElseIf List3.Text = "Italic" Then
Label1.FontItalic = True
ElseIf List3.Text = "Bold Italic" Then
Label1.FontItalic = True
Label1.FontBold = True
ElseIf List3.Text = "Regular" Then
Label1.FontItalic = False
Label1.FontBold = False
Else
Label1.FontItalic = False
Label1.FontBold = False
End If
End Sub
Private Sub LowerCase_Click()
If LowerCase.Value = 1 Then
Label1.Caption = LCase(Label1.Caption)
Else
Label1.Caption = "Sample Text"
End If
End Sub
Private Sub Strike_Click()
If Strike.Value = 1 Then
Label1.FontStrikethru = True
Else
Label1.FontStrikethru = False
End If
End Sub
Private Sub Underline_Click()
If Underline.Value = 1 Then
Label1.FontUnderline = True
Else
Label1.FontUnderline = False
End If
End Sub
Private Sub UpperCase_Click()
If UpperCase.Value = 1 Then
Label1.Caption = UCase(Label1.Caption)
Else
Label1.Caption = "Sample Text"
End If
End Sub