我在Select Case中计算的问题 [英] Problems with my calculation in Select Case
本文介绍了我在Select Case中计算的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我要感谢上次帮助过我的所有人。我重新开始了,一直试图从我的教授那里得到帮助。这是它工作的代码(YAY),但计算并不是每次我都无法让它工作。如果有人有任何想法
为什么它不起作用或什么。
I would like to thank all those who helped me last time. I restarted again and been trying to get help from my professor. Here is the code it works (YAY) but the calculation does not every single time I can't seem to get it to work. If anyone has any ideas why it won't be working or anything.
'****************************************************************************
'Program : SalespersonsCommissions
'Author : Elisabeth van der Wilt
'Student ID : 3341248
'Course ID : CMIS 214
'Assement : Assignment 2 ~ Program 1
'Date : March 27th 2018
'
'Purpose : To create a calculator for a salespersons commissions
' The application has two textboxes where they can enter
' their information. And three buttons Calculate,Clear,
' and Exit. There will be a message box to show if it was invalid.
'********************************************************************************
Public Class salesperson
Option Strict On
Option Explicit On
Private Sub BtnClear_Click(sender As Object, e As EventArgs) Handles BtnClear.Click
'clears the textboxes
TxtLevel.Text = ""
TxtSold.Text = ""
lblMessage.Text = ""
TxtLevel.Focus()
End Sub
Private Sub BtnExit_Click(sender As Object, e As EventArgs) Handles BtnExit.Click
'this will end the application
End
End Sub
Private Sub TxtLevel_TextChanged(sender As Object, e As EventArgs) Handles TxtLevel.TextChanged
'checks if the present value is a number
If Not IsNumeric(TxtLevel.Text) Then
MessageBox.Show("The Present value is NOT numeric.")
TxtLevel.Select() 'places cursor in that textbox
Exit Sub 'breaks out of procedure
End If
'checks if the present value is a number between 1 and 4
If Val(TxtLevel.Text) < 1 Or Val(TxtLevel.Text) > 4 Then
MessageBox.Show("The Present value is not between 1 - 4")
TxtLevel.Select() 'places cursor in that textbox.
Exit Sub 'breaks out of procedure
End If
End Sub
Private Sub TxtSold_TextChanged(sender As Object, e As EventArgs) Handles TxtSold.TextChanged
'checks if the present value is a number
If Not IsNumeric(TxtSold.Text) Then
MessageBox.Show("The Present value is NOT numeric.")
TxtSold.Select() 'places cursor in that textbox
Exit Sub 'breaks out of procedure
End If
'checks if the present value is a number between 1 and 100,000
If Val(TxtSold.Text) < 1 Or Val(TxtSold.Text) > 100000 Then
MessageBox.Show("The Present value is not between $1 - $100,000")
TxtSold.Select() 'places cursor in that textbox.
Exit Sub 'breaks out of procedure
End If
End Sub
Private Sub BtnCalculate_Click(sender As Object, e As EventArgs) Handles BtnCalculate.Click
'this is to declare all the label and textboxs I have.
Dim dblSold As Integer
Dim dblLevel As Double
Dim dblMessage As Double
lblMessage.Text = Format(dblMessage, "C") 'this formats the textbox to currency
Select Case dblLevel 'case determined by txtLevel
Case "1" 'determined by sales level
dblLevel = dblSold * 0.02 + 500
Case "2" 'determined by sales level
dblLevel = dblSold * 0.03 + 750
Case "3" 'determined by sales level
dblLevel = dblSold * 0.04 + 1000
Case "4" 'determined by sales level
dblLevel = dblSold * 0.05 + 1250
Case Else
Exit Select
End Select
End Sub
End Class
我将非常感谢所有可能的帮助。
I would appreciate all help that is possible.
推荐答案
Dim dblLevel As Double
Dim dblMessage As Double
lblMessage.Text = Format(dblMessage, "C") 'this formats the textbox to currency
Select Case dblLevel 'case determined by txtLevel
dbLevel始终为空,因此select只需退出。
在你的代码中是一个语句"结束"以关闭程序,使用"关闭"。"结束"杀死一个程序而不进行跟踪
这篇关于我在Select Case中计算的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文