急等!VB,输入一个三位正整数,判断奇偶性,是偶数拆分相加,反之相乘

2024-12-12 10:55:16
推荐回答(2个)
回答1:

Dim a As Integer
a = CInt(Text1.Text)
Dim c As Double
c = a Mod 2

If (a Mod 2) = 0 Then
a = CInt(Mid(Text1.Text, 1, 1)) + CInt(Mid(Text1.Text, 2, 1)) + CInt(Mid(Text1.Text, 3, 1))
Else
a = CInt(Mid(Text1.Text, 1, 1)) * CInt(Mid(Text1.Text, 2, 1)) * CInt(Mid(Text1.Text, 3, 1))
End If

回答2:

if innum mod 2=0 then
outsum=cint(mid(innum,1,1))+cint(mid(innum,2,1))+cint(mid(innum,3,1))

else
outsum=cint(mid(innum,1,1))*cint(mid(innum,2,1))*cint(mid(innum,3,1))
end if