我想獲得用戶對其信用評級的輸入,例如AAA,A,BBB等,然後爲此分配利率。例如,如果用戶具有良好的信用評級,例如AAA,我將收取1%的利率。從字符串輸入收集數字數據
我已經插入了我在VBA中用於這個特定功能的代碼,所以你有我想要的/它是如何工作的想法,雖然我刪除了各種行,因爲我只添加了代碼,以便更好地瞭解我正在努力。
creditRate = InputBox("Please enter credit rating:")
If creditRate = "AAA" Then GoTo intcalc Else
If creditRate = "A" Then GoTo intcalc Else
If creditRate = "BBB" Then GoTo intcalc Else
If creditRate = "BB" Then GoTo intcalc Else
If creditRate = "CCC" Then GoTo intcalc Else
If creditRate = "DDD" Then GoTo intcalc Else
If creditRate = "AAA" Then intRate = 0.01 Else
If creditRate = "A" Then intRate = 0.03 Else
If creditRate = "BBB" Then intRate = 0.05 Else
If creditRate = "BB" Then intRate = 0.06 Else
If creditRate = "CCC" Then intRate = 0.08 Else
If creditRate = "DDD" Then intRate = 0.1 Else
你** ** DEFINITELY沒有這樣的代碼在VBA - 即如果其他的語法是不合法的。此外,找到一種方法來避免'GoTo'跳轉。 99.99999%的時間是可以避免的。 –