vb期末考试,救救孩子!
手机话费计算:能够充话费,使用话费(每次使用金额可以变化,并要求自己输入)以及显示话费余额。充话费时,如果每次充值100元以上(含100),赠送充值金额的10%话费;充值在50-100(含50),赠送充值金额的5%话费;充值50元以下不赠送话费。使用时,如果余额不足10元,要提示用户充值,不足5元时显示不能使用(即不能输入使用话费)。如果能写出简单易懂的程序就最好了!!感激不尽!
还有可用话费余额应该怎么储存数据?
[

Dim BB As Single, FO As Object, FT As String Private Sub Command1_Click() If Val(Text3.Text) > 10 Then Set FO = CreateObject("Scripting.FileSystemObject") FT = App.Path & "\话费.txt" If FO.FileExists(FT) = True Then Kill FT '删除原"话费.txt"文件 If Val(Text3.Text) >= 100 Then BB = BB + Val(Text3.Text) * 1.1 ElseIf Val(Text3.Text) >= 50 Then BB = BB + Val(Text3.Text) * 1.05 ElseIf Val(Text3.Text) < 50 Then BB = BB + Val(Text3.Text) End If BB = Round(BB, 2) Call BJC Text2.Text = BB Open App.Path & "\话费.txt" For Append As #1 '创建新的"话费.txt"文件 Print #1, BB Close #1 Else MsgBox "话费充值不能小于 10 元!" End If End Sub Private Sub Form_Load() Open App.Path & "\话费.txt" For Input As #1 '读取话费 Input #1, AA Close #1 BB = Round(Val(AA), 2) Call BJC Text2.Text = BB End Sub Private Sub Text1_LostFocus() ' If Val(Text1.Text) > 0 Then Set FO = CreateObject("Scripting.FileSystemObject") FT = App.Path & "\话费.txt" If FO.FileExists(FT) = True Then Kill FT '删除原"话费.txt"文件 BB = BB - Val(Text1.Text) BB = Round(BB, 2) Text2.Text = BB Text1.Text = "" Open App.Path & "\话费.txt" For Append As #1 '创建新的"话费.txt"文件 Print #1, BB Close #1 Call BJC End If End Sub Private Sub BJC() If BB < 10 And BB >= 5 Then MsgBox "金额不足,请充值!" Text1.Enabled = True ElseIf BB < 5 Then MsgBox "可用话费余额不足,无法设置话费!" Text1.Enabled = False '可用话费余额不足,“当次使用话费”文本框失效 End If If BB >= 10 Then Text1.Enabled = True End If End Sub