如何控制另一程序中的Slider控件
1个回答
展开全部
VB可通过Slider控件的Scroll事件,获得Slider控件的Value 属性来控制某个控件的变化。
Scroll 事件(Slider 控件)
当单击控件或使用键盘命令移动 Slider 控件上的滑块时,该事件发生。
Value 属性
返回或设置对象的值。
以下是一段实现代码,控制Shape控件的宽高尺寸,在图片框上改变。
Option Explicit
Dim X As Long, Y As Long
Dim Po As Long
Private Sub Form_Load()
Picture1.ForeColor = <a href="https://www.baidu.com/s?wd=vb&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YdrHcsnhD3uHw-nAn3PyuB0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnH64PHR3nWTs" target="_blank" class="baidu-highlight">vb</a>Red
Slider1.Min = 0
Slider1.Max = 100
X = 500: Y = 500 * Picture1.Height / Picture1.Width
Po = 0
Shape1.BorderColor = <a href="https://www.baidu.com/s?wd=vb&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YdrHcsnhD3uHw-nAn3PyuB0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnH64PHR3nWTs" target="_blank" class="baidu-highlight">vb</a>White
Shape1.Top = 10
Shape1.Left = 10
Shape1.Height = Y
Shape1.Width = X
End Sub
Private Sub Slider1_Scroll()
If Slider1.Value > Po Then
X = X + Slider1.Value * 3
Y = Y + Slider1.Value * 3 * Picture1.Height / Picture1.Width
Else
X = X - Slider1.Value * 3
Y = Y - Slider1.Value * 3 * Picture1.Height / Picture1.Width
End If
Po = Slider1.Value
Shape1.Height = Y
Shape1.Width = X
End Sub
Scroll 事件(Slider 控件)
当单击控件或使用键盘命令移动 Slider 控件上的滑块时,该事件发生。
Value 属性
返回或设置对象的值。
以下是一段实现代码,控制Shape控件的宽高尺寸,在图片框上改变。
Option Explicit
Dim X As Long, Y As Long
Dim Po As Long
Private Sub Form_Load()
Picture1.ForeColor = <a href="https://www.baidu.com/s?wd=vb&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YdrHcsnhD3uHw-nAn3PyuB0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnH64PHR3nWTs" target="_blank" class="baidu-highlight">vb</a>Red
Slider1.Min = 0
Slider1.Max = 100
X = 500: Y = 500 * Picture1.Height / Picture1.Width
Po = 0
Shape1.BorderColor = <a href="https://www.baidu.com/s?wd=vb&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YdrHcsnhD3uHw-nAn3PyuB0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnH64PHR3nWTs" target="_blank" class="baidu-highlight">vb</a>White
Shape1.Top = 10
Shape1.Left = 10
Shape1.Height = Y
Shape1.Width = X
End Sub
Private Sub Slider1_Scroll()
If Slider1.Value > Po Then
X = X + Slider1.Value * 3
Y = Y + Slider1.Value * 3 * Picture1.Height / Picture1.Width
Else
X = X - Slider1.Value * 3
Y = Y - Slider1.Value * 3 * Picture1.Height / Picture1.Width
End If
Po = Slider1.Value
Shape1.Height = Y
Shape1.Width = X
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询