我目前正在开发第二个VBA项目,但我似乎无法找到错误。
这是一个带有多个文本框和组合框的用户表单,我将其放入文本框中 我尝试将一些文本框相乘并将结果放在另一个文本框中,然后将其保存到工作表上的单元格中。我的问题是乘法的结果总是导致零。我已经将文本框转换为Double类型,因此用数字计算应该没问题。
也许其他人可以在我的代码中找到错误?
Dim sheet As Worksheet
Dim Leerzeile As Long
Dim Produkt As double
Set sheet = ThisWorkbook.Sheets("sheet1")
With sheet
If tboxEinwaageCharge.Visible = True Then
.Cells(Leerzeile + 1, 7).Value = tboxEinwCh.Value
.Cells(Leerzeile + 1, 8).Value = tboxVol.Value
.Cells(Leerzeile + 1, 9).Value = cboxVerd.Value
.Cells(Leerzeile + 1, 10).Value = tboxCh1.Value
.Cells(Leerzeile + 1, 11).Value = tboxCh2.Value
.Cells(Leerzeile + 1, 12).Value = tboxCh3.Value
.Cells(Leerzeile + 1, 13).Value = tboxCh4.Value
.Cells(Leerzeile, 7).Value = tboxEinw.Value
.Cells(Leerzeile, 8).Value = tboxVol.Value
.Cells(Leerzeile, 9).Value = cboxVerd.Value
.Cells(Leerzeile, 10).Value = tboxKol1.Value
.Cells(Leerzeile, 11).Value = tboxKol2.Value
.Cells(Leerzeile, 12).Value = tboxKol3.Value
.Cells(Leerzeile, 13).Value = tboxKol4.Value
Produkt = CDbl(tboxEinw.value) * CDbl(cboxVerd.value) * CDbl(tboxVol.value)
tboxLZZ.Value = (((cdbl(tboxKol1.value) / Produkt) / 10) + ((cdbl(tboxKol2.value) / Produkt) / 10) + ((cdbl(tboxKol3.value) / Produkt) / 10) + ((cdbl(tboxKol4.value) / Produkt) / 10)) / 4
tboxLZZMW.Value = cdbl(tboxLZZ.value)
我很感激任何帮助! 感谢