【机房】充值

一、逻辑流程图



二、代码分享

Dim txtSQL As String
Dim txtSQL1 As String
Dim txtSQL2 As String
Dim MsgText As String
Dim mrc As adodb.Recordset  '连接BD表
Dim mrc1 As adodb.Recordset '连接student表
Dim mrc2 As adodb.Recordset '连接Recharge表
Dim cash1 As Integer
Dim cash2 As Integer

Private Sub cmdExit_Click()
    Unload Me
End Sub

Private Sub cmdOK_Click()
    '判断是否输入卡号
    If Not Testtxt(txtCardno.Text) Then
        MsgBox "请输入卡号!", 48, "提示"
        txtCardno.SetFocus
        Exit Sub
    End If
    
    If Not IsNumeric(Trim(txtCardno.Text)) Then
        MsgBox "卡号请输入数字!", 48, "提示"
        txtCardno.Text = ""
        txtCardno.SetFocus
        Exit Sub
    End If
    
    '判断是否输入充值金额
    If Not Testtxt(txtRecharge.Text) Then
        MsgBox "请输入充值金额!", 48, "提示"
        txtRecharge.SetFocus
        Exit Sub
    End If
    
    '判断金额是否为数字
    If Not IsNumeric(Trim(txtRecharge.Text)) Then
        MsgBox "充值金额请输入数字!", 48, "提示"
        txtRecharge.Text = ""
        txtRecharge.SetFocus
        Exit Sub
    End If

    '判断充值金额是否小于基础表最低金额
    txtSQL = "select*from BasicData_Info"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    
    '充值金额与最低金额比较
    If Val(txtRecharge.Text) < mrc.Fields(5) Then
        MsgBox "充值金额不得小于最低金额,请重新输入!", 48, "提示"
        txtRecharge.Text = ""
        txtRecharge.SetFocus
        Exit Sub
    End If
    
    '连接student表判断卡号是否存在
    txtSQL1 = "select*from student_Info where cardno='" & Trim(txtCardno.Text) & "'"
    Set mrc1 = ExecuteSQL(txtSQL1, MsgText)
    
    If mrc1.EOF = True Then
        MsgBox "该卡号不存在或者被停用,请重新输入!", 48, "提示"
        txtCardno.Text = ""
        txtCardno.SetFocus
        Exit Sub
    Else
        cash1 = mrc1.Fields(7)
        '更新recharge表
        txtSQL2 = "select*from Recharge_Info"
        Set mrc2 = ExecuteSQL(txtSQL2, MsgText)
        
        mrc2.AddNew
        mrc2.Fields(1) = mrc1.Fields(1)
        mrc2.Fields(2) = mrc1.Fields(0)
        mrc2.Fields(3) = Trim(txtRecharge.Text)
        mrc2.Fields(4) = Date
        mrc2.Fields(5) = Time
        mrc2.Fields(6) = mrc1.Fields(9)
        mrc2.Fields(7) = mrc1.Fields(10)
        mrc2.Update
        
        '将总金额更新到student表
        cash2 = cash1 + Val(txtRecharge.Text)
        mrc1.Fields(7) = cash2
        mrc1.Update
        
        '在txtnote中显示充值信息
        txtNote.Text = "充值卡号:" & txtCardno.Text & vbCrLf & _
                        "原金额:" & cash1 & vbCrLf & _
                        "充值金额:" & txtRecharge.Text & vbCrLf & _
                        "现有金额:" & cash2 & vbCrLf & _
                        "充值日期:" & Date & vbCrLf & _
                        "充值时间:" & Time & vbCrLf & _
                        "充值教师:" & UserName
                        
                        mrc.Close
                        mrc1.Close
                        mrc2.Close
                        MsgBox "充值成功!", 48, "提示"
                        txtCardno.Text = ""
                        txtRecharge.Text = ""
                        txtNote.Text = ""
        End If
        
End Sub

        在txtnote中显示我们发现加了vbcrlf代码后,文档中没有回车换行,还是依旧堆积在第一行中,其实还少了一个步骤就是属性multiline值改为true就OK了。


代码仓库

vbCr=Chr(13) 回车符
vbLf=Chr(10) 换行符
vbCrLf=Chr(13) & Chr(10) 回车+换行符
例如vbcrlf使用方法:
response.write("hello!world!")输出为:
hello!world!
response.write("hello!"&vbcrlf&"world!")输出为:
hello!
world!




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值