VB,多按钮的相互操作处理

Option Explicit
Dim total As Integer, current As Integer

Private Sub cmd2_Click(Index As Integer)
    If Index = 0 Then current = 0
    If Index = 1 Then current = current - 1
    If Index = 2 Then current = current + 1
    If Index = 3 Then current = total

    If current = 0 Then
        Call Ena_Button(cmd2(0), cmd2(1), cmd2(2), cmd2(3), 0, 0, 1, 1)
    ElseIf current = total Then
        Call Ena_Button(cmd2(0), cmd2(1), cmd2(2), cmd2(3), 1, 1, 0, 0)
    Else
        Call Ena_Button(cmd2(0), cmd2(1), cmd2(2), cmd2(3), 1, 1, 1, 1)
    End If

End Sub

Private Sub Cmd1_Click(Index As Integer)    '不对中间按钮设置 Enable

    If Index = 0 Then    '添加时
        Call Ena_Button(Cmd1(0), Cmd1(1), Cmd1(3), Cmd1(4), 0, 0, 1, 1)
    End If
    If Index = 1 Then    '修改时
        Call Ena_Button(Cmd1(0), Cmd1(1), Cmd1(3), Cmd1(4), 0, 0, 1, 1)
    End If
    If Index = 2 Then    '删除时
        Index = 3
    End If
    If Index = 4 Then

        Index = 3
    End If

    If Index = 3 Then    '取消时
        Call Ena_Button(Cmd1(0), Cmd1(1), Cmd1(3), Cmd1(4), 1, 1, 0, 0)
    End If

End Sub

Private Sub Form_Load()
    total = 6
    current = 0
    cmd2_Click (0)    '初始按钮状态
    Cmd1_Click (3)    '初始按钮状态
End Sub

Public Sub Ena_Button(C1 As CommandButton, C2 As CommandButton, C3 As CommandButton, C4 As CommandButton, n1 As Integer, n2 As Integer, n3 As Integer, n4 As Integer)
'''用按钮控制数据记录移动时,改变按钮的可用状态
'''设置按钮是否可用.
'''C1,参与进来的按钮
'''n1,对应标识
'''
'''
C1.Enabled = n1
C2.Enabled = n2
C3.Enabled = n3
C4.Enabled = n4
End Sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值