vb Check1问题
窗体1有一个MSFlexGrid1,还有一个按键Command1,和一个Check1,在MSFlexGrid1(1,1)以下行的(列不变)每个单元格都只有一个3位数的数字...
窗体1有一个MSFlexGrid1,还有一个按键Command1,和一个Check1,在MSFlexGrid1(1,1)以下行的(列不变)每个单元格都只有一个3位数的数字如在MSFlexGrid1(1,1)是567,MSFlexGrid1(2,1)是019,MSFlexGrid1(3,1)是428,MSFlexGrid1(4,1)是028
效果:当Check1被选择时,点击Command1,那么在MSFlexGrid1每个单元格里数据的和等于14的将被删除,然后从新把保留的数据显示在MSFlexGrid1,如上面的例子MSFlexGrid1(3,1)是428,4+2+8=14,那么它将被删除,重新显示MSFlexGrid1(1,1)是567,MSFlexGrid1(2,1)是019,MSFlexGrid1(3,1)是028,这时428行已被删除。这段代码该如何写 展开
效果:当Check1被选择时,点击Command1,那么在MSFlexGrid1每个单元格里数据的和等于14的将被删除,然后从新把保留的数据显示在MSFlexGrid1,如上面的例子MSFlexGrid1(3,1)是428,4+2+8=14,那么它将被删除,重新显示MSFlexGrid1(1,1)是567,MSFlexGrid1(2,1)是019,MSFlexGrid1(3,1)是028,这时428行已被删除。这段代码该如何写 展开
展开全部
'新建一个文本文档,将以下代码复制到文本文档,然后文本文档改名为form1.frm,用vb6.0编译器打开,运行之。。。。
VERSION 5.00
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form Form2
Caption = "Form2"
ClientHeight = 5430
ClientLeft = 60
ClientTop = 450
ClientWidth = 8505
LinkTopic = "Form2"
ScaleHeight = 5430
ScaleWidth = 8505
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 615
Left = 960
TabIndex = 1
Top = 3000
Width = 2055
End
Begin MSHierarchicalFlexGridLib.MSHFlexGrid MSHFlexGrid1
Height = 2055
Left = 360
TabIndex = 0
Top = 120
Width = 5895
_ExtentX = 10398
_ExtentY = 3625
_Version = 393216
_NumberOfBands = 1
_Band(0).Cols = 2
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim i As Long, a As Integer, j As Integer, b As Integer, c() As Integer, d As Long
ReDim c(0)
With MSHFlexGrid1
For i = 1 To .Rows - 1
a = Len(.TextMatrix(i, 1))
b = 0
For j = 1 To a
b = b + Val(Mid(.TextMatrix(i, 1), j, 1))
Next j
If b = 14 Then
If c(0) = 0 Then
c(0) = i
Else
d = UBound(c)
ReDim Preserve c(d + 1)
c(d + 1) = i
End If
End If
Next i
If c(0) <> 0 Then
For i = 0 To UBound(c)
.RemoveItem c(i)
Next i
End If
End With
End Sub
Private Sub Form_Load()
Dim i As Long
With MSHFlexGrid1
.Cols = 4
.Rows = 5
.Col = 1
.Row = 1
.Text = "567"
.Row = 2
.Text = "019"
.Row = 3
.Text = "428"
.Row = 4
.Text = "028"
End With
End Sub
VERSION 5.00
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form Form2
Caption = "Form2"
ClientHeight = 5430
ClientLeft = 60
ClientTop = 450
ClientWidth = 8505
LinkTopic = "Form2"
ScaleHeight = 5430
ScaleWidth = 8505
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 615
Left = 960
TabIndex = 1
Top = 3000
Width = 2055
End
Begin MSHierarchicalFlexGridLib.MSHFlexGrid MSHFlexGrid1
Height = 2055
Left = 360
TabIndex = 0
Top = 120
Width = 5895
_ExtentX = 10398
_ExtentY = 3625
_Version = 393216
_NumberOfBands = 1
_Band(0).Cols = 2
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim i As Long, a As Integer, j As Integer, b As Integer, c() As Integer, d As Long
ReDim c(0)
With MSHFlexGrid1
For i = 1 To .Rows - 1
a = Len(.TextMatrix(i, 1))
b = 0
For j = 1 To a
b = b + Val(Mid(.TextMatrix(i, 1), j, 1))
Next j
If b = 14 Then
If c(0) = 0 Then
c(0) = i
Else
d = UBound(c)
ReDim Preserve c(d + 1)
c(d + 1) = i
End If
End If
Next i
If c(0) <> 0 Then
For i = 0 To UBound(c)
.RemoveItem c(i)
Next i
End If
End With
End Sub
Private Sub Form_Load()
Dim i As Long
With MSHFlexGrid1
.Cols = 4
.Rows = 5
.Col = 1
.Row = 1
.Text = "567"
.Row = 2
.Text = "019"
.Row = 3
.Text = "428"
.Row = 4
.Text = "028"
End With
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询