vb 编程题
3、设置字体属性编写一段用于设置字体属性的程序,要求如下:a.启动工程后,自动在“字体”列表框中列出当前系统中可用的屏幕字体供用户选择。b.“字号”简单组合框中列出部分字...
3、设置字体属性
编写一段用于设置字体属性的程序,要求如下:
a. 启动工程后,自动在“字体”列表框中列出当前系统中可用的屏幕字体供用户选择。
b. “字号”简单组合框中列出部分字号供用户选择,默认值为10磅,用户也可根据需要在文本框中直接输入字号大小。
c. 通过滚动“红”、“绿”、“蓝”3个水平滚动条可以设置字体颜色。
d. 两个“底纹”单选按钮,一个用于取消低纹设置,一个用于设置红色底纹。
e. 所做的任何设置都在“示例”选项卡中立即显示效果,单击“取消”按钮将恢复初始设置,单击“确定”按钮将结束工程。
提示:在窗体上放置6个标签、4个框架、1个列表框、1个组合框、4个选择框、两个单选按钮、3个水平滚动条和两个命令按钮,界面如图所示(此界面只作为参考,界面风格可自定)。 展开
编写一段用于设置字体属性的程序,要求如下:
a. 启动工程后,自动在“字体”列表框中列出当前系统中可用的屏幕字体供用户选择。
b. “字号”简单组合框中列出部分字号供用户选择,默认值为10磅,用户也可根据需要在文本框中直接输入字号大小。
c. 通过滚动“红”、“绿”、“蓝”3个水平滚动条可以设置字体颜色。
d. 两个“底纹”单选按钮,一个用于取消低纹设置,一个用于设置红色底纹。
e. 所做的任何设置都在“示例”选项卡中立即显示效果,单击“取消”按钮将恢复初始设置,单击“确定”按钮将结束工程。
提示:在窗体上放置6个标签、4个框架、1个列表框、1个组合框、4个选择框、两个单选按钮、3个水平滚动条和两个命令按钮,界面如图所示(此界面只作为参考,界面风格可自定)。 展开
展开全部
添加以下控件,所有属性都不必改动,直接粘贴代码即可。
Combo1,Command1,Command2,Label1,Label2,Label3,Label4,Label5,Label6,List1,Option1,Option2,Slider1,Slider2,Slider3.
代码如下。
==============================================
Dim f As StdFont, r As Integer, g As Integer, b As Integer
Sub run()
Label2.Font.Name = f.Name
Label2.ForeColor = RGB(r, g, b)
Label2.Font.Size = f.Size
End Sub
Sub Default()
Label2.Font.Name = "宋体"
Label2.Font.Size = 10
Label2.ForeColor = vbBlack
Label2.BackColor = vbButtonFace
Combo1.ListIndex = 4
Slider1.Value = 0
Slider2.Value = 0
Slider3.Value = 0
End Sub
Private Sub Combo1_Change()
On Error Resume Next
f.Size = Combo1.Text
run
End Sub
Private Sub Combo1_Click()
f.Size = Combo1.Text
run
End Sub
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
Default
End Sub
Private Sub Form_Load()
BorderStyle = 3
Width = 8265
Caption = "字体属性程序"
Height = 5500
Label1.Move 0, 0
Label2.Move 2400, 120
Label3.Move 0, 2640
Label4.Move 120, 3360
Label5.Move 120, 3720
Label6.Move 120, 4080
List1.Move 0, 240, 2295, 2400
Combo1.Move 0, 2880, 2295
Slider1.Move 480, 3360, 5535, 375
Slider2.Move 480, 3720, 5535, 375
Slider3.Move 480, 4080, 5535, 375
Command1.Move 5160, 4560, 1095, 375
Command2.Move 6600, 4560, 1095, 375
Option1.Move 6120, 3240, 1815, 495
Option2.Move 6120, 3840, 1815, 495
Set f = New StdFont
Dim i As Integer
Label1.Caption = "字体:"
Label1.AutoSize = True
Label2.Caption = "示例文字" & vbCrLf & "Example Text"
Label3.Caption = "字号:"
Label3.AutoSize = True
Label4.Caption = "红"
Label4.AutoSize = True
Label5.Caption = "绿"
Label5.AutoSize = True
Label6.Caption = "蓝"
Label6.AutoSize = True
Command1.Caption = "确定"
Command2.Caption = "取消"
Option1.Caption = "设置红色底纹"
Option2.Caption = "取消底纹"
Combo1.AddItem 2
Combo1.AddItem 4
Combo1.AddItem 6
Combo1.AddItem 8
Combo1.AddItem 10
Combo1.AddItem 12
Combo1.AddItem 14
Combo1.AddItem 16
Combo1.AddItem 18
Combo1.AddItem 20
Combo1.AddItem 24
Combo1.AddItem 28
Combo1.AddItem 36
Combo1.AddItem 72
Label2.AutoSize = True
Slider1.Min = 0
Slider1.Max = 255
Slider1.TickFrequency = 10
Slider2.Min = 0
Slider2.Max = 255
Slider2.TickFrequency = 10
Slider3.Min = 0
Slider3.Max = 255
Slider3.TickFrequency = 10
'Exit Sub
For i = 0 To Screen.FontCount
List1.AddItem Screen.Fonts(i)
Next
Default
End Sub
Private Sub List1_Click()
f.Name = List1.Text
run
End Sub
Private Sub Option1_Click()
Label2.BackColor = vbRed
End Sub
Private Sub Option2_Click()
Label2.BackColor = vbButtonFace
End Sub
Private Sub Slider1_Change()
r = Slider1.Value
run
End Sub
Private Sub Slider2_Change()
g = Slider2.Value
run
End Sub
Private Sub Slider3_Change()
b = Slider3.Value
run
End Sub
Combo1,Command1,Command2,Label1,Label2,Label3,Label4,Label5,Label6,List1,Option1,Option2,Slider1,Slider2,Slider3.
代码如下。
==============================================
Dim f As StdFont, r As Integer, g As Integer, b As Integer
Sub run()
Label2.Font.Name = f.Name
Label2.ForeColor = RGB(r, g, b)
Label2.Font.Size = f.Size
End Sub
Sub Default()
Label2.Font.Name = "宋体"
Label2.Font.Size = 10
Label2.ForeColor = vbBlack
Label2.BackColor = vbButtonFace
Combo1.ListIndex = 4
Slider1.Value = 0
Slider2.Value = 0
Slider3.Value = 0
End Sub
Private Sub Combo1_Change()
On Error Resume Next
f.Size = Combo1.Text
run
End Sub
Private Sub Combo1_Click()
f.Size = Combo1.Text
run
End Sub
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
Default
End Sub
Private Sub Form_Load()
BorderStyle = 3
Width = 8265
Caption = "字体属性程序"
Height = 5500
Label1.Move 0, 0
Label2.Move 2400, 120
Label3.Move 0, 2640
Label4.Move 120, 3360
Label5.Move 120, 3720
Label6.Move 120, 4080
List1.Move 0, 240, 2295, 2400
Combo1.Move 0, 2880, 2295
Slider1.Move 480, 3360, 5535, 375
Slider2.Move 480, 3720, 5535, 375
Slider3.Move 480, 4080, 5535, 375
Command1.Move 5160, 4560, 1095, 375
Command2.Move 6600, 4560, 1095, 375
Option1.Move 6120, 3240, 1815, 495
Option2.Move 6120, 3840, 1815, 495
Set f = New StdFont
Dim i As Integer
Label1.Caption = "字体:"
Label1.AutoSize = True
Label2.Caption = "示例文字" & vbCrLf & "Example Text"
Label3.Caption = "字号:"
Label3.AutoSize = True
Label4.Caption = "红"
Label4.AutoSize = True
Label5.Caption = "绿"
Label5.AutoSize = True
Label6.Caption = "蓝"
Label6.AutoSize = True
Command1.Caption = "确定"
Command2.Caption = "取消"
Option1.Caption = "设置红色底纹"
Option2.Caption = "取消底纹"
Combo1.AddItem 2
Combo1.AddItem 4
Combo1.AddItem 6
Combo1.AddItem 8
Combo1.AddItem 10
Combo1.AddItem 12
Combo1.AddItem 14
Combo1.AddItem 16
Combo1.AddItem 18
Combo1.AddItem 20
Combo1.AddItem 24
Combo1.AddItem 28
Combo1.AddItem 36
Combo1.AddItem 72
Label2.AutoSize = True
Slider1.Min = 0
Slider1.Max = 255
Slider1.TickFrequency = 10
Slider2.Min = 0
Slider2.Max = 255
Slider2.TickFrequency = 10
Slider3.Min = 0
Slider3.Max = 255
Slider3.TickFrequency = 10
'Exit Sub
For i = 0 To Screen.FontCount
List1.AddItem Screen.Fonts(i)
Next
Default
End Sub
Private Sub List1_Click()
f.Name = List1.Text
run
End Sub
Private Sub Option1_Click()
Label2.BackColor = vbRed
End Sub
Private Sub Option2_Click()
Label2.BackColor = vbButtonFace
End Sub
Private Sub Slider1_Change()
r = Slider1.Value
run
End Sub
Private Sub Slider2_Change()
g = Slider2.Value
run
End Sub
Private Sub Slider3_Change()
b = Slider3.Value
run
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询