Я думаю, что мой код в порядке, но он показывает несоответствие типов после запуска, может кто-нибудь помочь? (Несоответствие типов от пола)
Sub tuitioncal()
Dim Name As String
Dim Gender As String
Dim LocalID As String
Dim CreditUD As Integer
Dim GenderAbb As String
Dim tuitionFee As Double
Dim uniFee As Double
Dim totalFee As Double
Name = InputBox("Enter your FULL name:", "Tuition & Fees Calculator")
Gender = InputBox("Enter your gender: Male/Female", "Tuition & Fees Calculator")
LocalID = InputBox("Enter your status: Local or Non-Local", "Tuition & Fees Calculator")
CreditUD = InputBox("Enter the total numbers of credits you are taking:", "Tuition & Fees Calculator")
If Gender = "Female" Or "F" Then
GenderAbb = "Ms."
ElseIf Gender = "Male" Or "M" Then
GenderAbb = "Mr."
End If
'some code afterwards
Спасибо всем! Я уже выполнил свой код, но все еще сталкиваюсь с трудностями при запуске программы, какие-либо предложения?
Option Explicit
Sub tuitioncal()
Dim Name As String
Dim Gender As Variant
Dim LocalID As String
Dim CreditUD As Integer
Dim sCreditUD As String
Dim GenderAbb As String
Dim tuitionFee As Double
Dim uniFee As Double
Dim totalFee As Double
Name = InputBox("Enter your FULL name:", "Tuition & Fees Calculator")
Gender = InputBox("Enter your gender: Male/Female", "Tuition & Fees Calculator")
LocalID = InputBox("Enter your status: Local or Non-Local", "Tuition & Fees Calculator")
sCredit = InputBox("Enter the total numbers of credits you are taking:", "Tuition & Fees Calculator")
If Not IsNumeric(sCredit) Then
MsgBox sCredit & " is not a numeric value. Aborting."
Exit Sub
End If
CreditUD = Int(sCredit)
If Gender = "Female" Or Gender = "F" Then
GenderAbb = "Ms."
ElseIf Gender = "Male" Or Gender = "M" Then
GenderAbb = "Mr."
End If
Do While LocalID = "Local"
If CreditUD >= 8 Then
tuitionFee = 21050 / 2
ElseIf CreditUD > 8 And CreditUD <= 21 Then
tuitionFee = 21050
ElseIf CreditUD > 21 Then
tuitionFee = 21050 + (CreditUD - 21) * 2670
End If
Loop
Do While LocalID = "Non-Local"
If CreditUD >= 12 And CreditUD <= 21 Then
tuitionFee = 60000
ElseIf CreditUD > 21 Then
tuitionFee = 60000 + (CreditUD - 21) * 4030
End If
Loop
uniFee = 400 + CreditUD * 50
totalFee = uniFee + tuitionFee
tuitionFee = Format(tuitionFee, "$#####.00")
uniFee = Format(uniFee, "$#####.00")
totalFee = Format(totalFee, "$#####.00")
MsgBox GenderAbb & Name & "," & VBA.vbCrLf & VBA.vbCrLf & "Based on your inputs - " _
& LocalID & "student and" & CreditUD & "credits:" & VBA.vbCrLf & VBA.vbCrLf & _
"Your tuition fee is" & tuitionFee & VBA.vbCrLf & "Your university fees is" & uniFee & _
VBA.vbCrLf & "Your Total fees is" & totalFee
End Sub
Могу ли я улучшить код?