0
我最近寫了這個簡短的函數,但在VBA中很少有經驗,我不明白爲什麼這不起作用。VBA(Excel)問題與校驗數公式
Sub barcodedigit()
Dim barcode(12) As Variant
Dim i As Integer
Dim oddscount As Integer
Dim evenscount As Integer
Dim evensnumbers As Integer
Dim oddsnumbers As Integer
Dim finalnumber As Double
Dim remainder As Integer
oddsnumbers = 0
evensnumbers = 0
For i = 1 To 12
barcode(i) = InputBox("Please enter number" & i)
Next i
For i = 1 To 12
If barcode(i) Mod 2 = 0 Then
evenscount = evenscount + 1 And evensnumbers = evensnumbers + barcode(i)
Else
oddscount = oddscount + 1 And oddsnumbers = oddsnumbers + barcode(i)
End If
Next i
oddsnumbers = oddsnumbers * 3
finalnumber = oddsnumbers + evensnumbers
remainder = finalnumber Mod 10
MsgBox ("Oddscount is equal to " & oddscount & vbNewLine & "Remainder is equal to" & " " & remainder)
End Sub
我在這裏的問題是,這是設置每個結果爲0(oddscount &餘數),即使這按理應該工作。
任何幫助表示讚賞。
編輯::刪除和完美工作!
不要以爲你需要和,只需使用2行代碼。 –