滚动条 Vb6 查询
ScrollBar Vb6 Query
我在 VB6
中有一个应用程序,在按下添加按钮后,字段会添加到 UserControl
。
我需要的是用 ScrollBar
管理那些 UserControl
以便 User 可以在不需要放大表格的情况下向下移动栏.
目前这是完整的代码:
Dim indice As Integer
Dim indicee As Integer
Private Sub btnAñadir_Click()
indice = indice + 1 'aumentamos el index
indicee = indicee + 0 'lo iniciamos en 0
uc1(indicee).Visible = True
'Label y TextBox de tipo
lblTipo(indicee).Visible = True
cmbAddTipo(indicee).Visible = True
'Label y TextBox de prefijo
lblAddPrefijo(indicee).Visible = True
txtAddPrefijo(indicee).Visible = True
'Label y TextBox de número
lblAddNum(indicee).Visible = True
txtAddNumero(indicee).Visible = True
chkAddPrincipal(indicee).Visible = True
'Label y TextBox de vínculo
lblAddVin(indicee).Visible = True
cmbAddVinculo(indicee).Visible = True
'uc1
Load uc1(indice) ' creamos el control
uc1(indice).Visible = True ' lo hacemos visible
uc1(indice).Top = uc1(indice - 1).Top + uc1(indice - 1).Height + 20
'lblTipo
Load lblTipo(indice)
Set lblTipo(indice).Container = uc1(indice)
lblTipo(indice).Visible = True
lblTipo(indice).Top = lblTipo(indice - 1).Top
'cmbAddTipo
Load cmbAddTipo(indice)
Set cmbAddTipo(indice).Container = uc1(indice)
cmbAddTipo(indice).Visible = True
cmbAddTipo(indice).Top = cmbAddTipo(indice - 1).Top
'lblAddPrefijo
Load lblAddPrefijo(indice)
Set lblAddPrefijo(indice).Container = uc1(indice)
lblAddPrefijo(indice).Visible = True
lblAddPrefijo(indice).Top = lblAddPrefijo(indice - 1).Top
'txtAddPrefijo
Load txtAddPrefijo(indice)
Set txtAddPrefijo(indice).Container = uc1(indice)
txtAddPrefijo(indice).Visible = True
txtAddPrefijo(indice).Top = txtAddPrefijo(indice - 1).Top
'lblAddNum
Load lblAddNum(indice)
Set lblAddNum(indice).Container = uc1(indice)
lblAddNum(indice).Visible = True
lblAddNum(indice).Top = lblAddNum(indice - 1).Top
'txtAddNumero
Load txtAddNumero(indice)
Set txtAddNumero(indice).Container = uc1(indice)
txtAddNumero(indice).Visible = True
txtAddNumero(indice).Top = txtAddNumero(indice - 1).Top
'checkAddPrincipal
Load chkAddPrincipal(indice)
Set chkAddPrincipal(indice).Container = uc1(indice)
chkAddPrincipal(indice).Visible = True
chkAddPrincipal(indice).Top = chkAddPrincipal(indice - 1).Top
'lblAddVin
Load lblAddVin(indice)
Set lblAddVin(indice).Container = uc1(indice)
lblAddVin(indice).Visible = True
lblAddVin(indice).Top = lblAddVin(indice - 1).Top
'cmbAddVinculo
Load cmbAddVinculo(indice)
Set cmbAddVinculo(indice).Container = uc1(indice)
cmbAddVinculo(indice).Visible = True
cmbAddVinculo(indice).Top = cmbAddVinculo(indice - 1).Top
End Sub
Private Sub Form_Load()
'scrollAdd
scrollAdd.Min = 0
scrollAdd.Max = 1000
scrollAdd.SmallChange = Screen.TwipsPerPixelX * 10
scrollAdd.LargeChange = scrollAdd.SmallChange
End Sub
Private Sub scrollAdd_Change()
UserControl1
End Sub
Private Sub scrollAdd_Scroll()
UserControl1
End Sub
Private Sub UserControl1()
Dim c As Control
For Each c In Me.Controls
If c.Container.Name = "uc1" And Not TypeOf c Is scrollAdd Then
c.Down = c.Down - (oldPos - scrollAdd.Value)
End If
Next
oldPos = scrollAdd.Value
End Sub
在使用添加按钮添加了几个字段后,我可以使用 ScrollBar
下载表单,该怎么做?
当我按下 ScrollBar I get the message: Sub or Function is not defined vb6
并且出现此错误时:Private Sub UserControl1()
Private Sub Command1_Click()
Load txtCode(txtCode.UBound + 1)
txtCode(txtCode.UBound).Top = txtCode(txtCode.UBound - 1).Top +
txtCode(txtCode.UBound - 1).Height
txtCode(txtCode.UBound).Text = txtCode.UBound
txtCode(txtCode.UBound).Visible = True
Picture2.Height = (txtCode(txtCode.UBound).Top +
txtCode(txtCode.UBound).Height) + 150
End Sub
Private Sub Form_Load()
Picture2.Top = Picture1.Top
Picture2.Left = Picture1.Left
Picture2.Height = Picture1.Height
Picture2.Width = Picture2.Width
End Sub
Private Sub Picture2_Resize()
If Picture2.Height > Picture1.Height Then
If Not HScroll1.Visible Then
HScroll1.Visible = True
VScroll1.Visible = True
End If
VScroll1.Max = (Picture2.Height - Picture1.Height) /
txtCode(txtCode.UBound).Height
VScroll1.Min = 0
VScroll1.Value = 0
Else
If HScroll1.Visible Then
HScroll1.Visible = False
VScroll1.Visible = False
End If
End If
End Sub
Private Sub VScroll1_Change()
Picture2.Top = -(VScroll1.Value * txtCode(txtCode.UBound).Height)
End Sub
您可以在下面的 link 中参考更多信息:
我在 VB6
中有一个应用程序,在按下添加按钮后,字段会添加到 UserControl
。
我需要的是用 ScrollBar
管理那些 UserControl
以便 User 可以在不需要放大表格的情况下向下移动栏.
目前这是完整的代码:
Dim indice As Integer
Dim indicee As Integer
Private Sub btnAñadir_Click()
indice = indice + 1 'aumentamos el index
indicee = indicee + 0 'lo iniciamos en 0
uc1(indicee).Visible = True
'Label y TextBox de tipo
lblTipo(indicee).Visible = True
cmbAddTipo(indicee).Visible = True
'Label y TextBox de prefijo
lblAddPrefijo(indicee).Visible = True
txtAddPrefijo(indicee).Visible = True
'Label y TextBox de número
lblAddNum(indicee).Visible = True
txtAddNumero(indicee).Visible = True
chkAddPrincipal(indicee).Visible = True
'Label y TextBox de vínculo
lblAddVin(indicee).Visible = True
cmbAddVinculo(indicee).Visible = True
'uc1
Load uc1(indice) ' creamos el control
uc1(indice).Visible = True ' lo hacemos visible
uc1(indice).Top = uc1(indice - 1).Top + uc1(indice - 1).Height + 20
'lblTipo
Load lblTipo(indice)
Set lblTipo(indice).Container = uc1(indice)
lblTipo(indice).Visible = True
lblTipo(indice).Top = lblTipo(indice - 1).Top
'cmbAddTipo
Load cmbAddTipo(indice)
Set cmbAddTipo(indice).Container = uc1(indice)
cmbAddTipo(indice).Visible = True
cmbAddTipo(indice).Top = cmbAddTipo(indice - 1).Top
'lblAddPrefijo
Load lblAddPrefijo(indice)
Set lblAddPrefijo(indice).Container = uc1(indice)
lblAddPrefijo(indice).Visible = True
lblAddPrefijo(indice).Top = lblAddPrefijo(indice - 1).Top
'txtAddPrefijo
Load txtAddPrefijo(indice)
Set txtAddPrefijo(indice).Container = uc1(indice)
txtAddPrefijo(indice).Visible = True
txtAddPrefijo(indice).Top = txtAddPrefijo(indice - 1).Top
'lblAddNum
Load lblAddNum(indice)
Set lblAddNum(indice).Container = uc1(indice)
lblAddNum(indice).Visible = True
lblAddNum(indice).Top = lblAddNum(indice - 1).Top
'txtAddNumero
Load txtAddNumero(indice)
Set txtAddNumero(indice).Container = uc1(indice)
txtAddNumero(indice).Visible = True
txtAddNumero(indice).Top = txtAddNumero(indice - 1).Top
'checkAddPrincipal
Load chkAddPrincipal(indice)
Set chkAddPrincipal(indice).Container = uc1(indice)
chkAddPrincipal(indice).Visible = True
chkAddPrincipal(indice).Top = chkAddPrincipal(indice - 1).Top
'lblAddVin
Load lblAddVin(indice)
Set lblAddVin(indice).Container = uc1(indice)
lblAddVin(indice).Visible = True
lblAddVin(indice).Top = lblAddVin(indice - 1).Top
'cmbAddVinculo
Load cmbAddVinculo(indice)
Set cmbAddVinculo(indice).Container = uc1(indice)
cmbAddVinculo(indice).Visible = True
cmbAddVinculo(indice).Top = cmbAddVinculo(indice - 1).Top
End Sub
Private Sub Form_Load()
'scrollAdd
scrollAdd.Min = 0
scrollAdd.Max = 1000
scrollAdd.SmallChange = Screen.TwipsPerPixelX * 10
scrollAdd.LargeChange = scrollAdd.SmallChange
End Sub
Private Sub scrollAdd_Change()
UserControl1
End Sub
Private Sub scrollAdd_Scroll()
UserControl1
End Sub
Private Sub UserControl1()
Dim c As Control
For Each c In Me.Controls
If c.Container.Name = "uc1" And Not TypeOf c Is scrollAdd Then
c.Down = c.Down - (oldPos - scrollAdd.Value)
End If
Next
oldPos = scrollAdd.Value
End Sub
在使用添加按钮添加了几个字段后,我可以使用 ScrollBar
下载表单,该怎么做?
当我按下 ScrollBar I get the message: Sub or Function is not defined vb6
并且出现此错误时:Private Sub UserControl1()
Private Sub Command1_Click()
Load txtCode(txtCode.UBound + 1)
txtCode(txtCode.UBound).Top = txtCode(txtCode.UBound - 1).Top +
txtCode(txtCode.UBound - 1).Height
txtCode(txtCode.UBound).Text = txtCode.UBound
txtCode(txtCode.UBound).Visible = True
Picture2.Height = (txtCode(txtCode.UBound).Top +
txtCode(txtCode.UBound).Height) + 150
End Sub
Private Sub Form_Load()
Picture2.Top = Picture1.Top
Picture2.Left = Picture1.Left
Picture2.Height = Picture1.Height
Picture2.Width = Picture2.Width
End Sub
Private Sub Picture2_Resize()
If Picture2.Height > Picture1.Height Then
If Not HScroll1.Visible Then
HScroll1.Visible = True
VScroll1.Visible = True
End If
VScroll1.Max = (Picture2.Height - Picture1.Height) /
txtCode(txtCode.UBound).Height
VScroll1.Min = 0
VScroll1.Value = 0
Else
If HScroll1.Visible Then
HScroll1.Visible = False
VScroll1.Visible = False
End If
End If
End Sub
Private Sub VScroll1_Change()
Picture2.Top = -(VScroll1.Value * txtCode(txtCode.UBound).Height)
End Sub
您可以在下面的 link 中参考更多信息: