0

我必须启用选项脚本,才能正确使用 OpenXML 包。完成后,关于从一种类型到另一种类型的隐式转换,我遇到了几个错误。

Label6.Text = FormatNumber(CInt(Form3.Label12.Text), "0.00") 'O.S. On disallows implicit conversions from String to Integer'

hrrspk.Add(Form3.ListBox2.Items(i)) 'O.S. On disallows implicit conversions from Double to Integer'

tsdom.Add(((hrrspk(ts) - CInt(Label6.Text)) * (CInt(Label3.Text) - CInt(Label4.Text)) / (CInt(Label6.Text))) + CInt(Label4.Text)) 'O.S. On disallows implicit conversions from Double to Integer'

hrrnativexcel = CreateObject("EXCEL.APPLICATION") 'O.S. On disallows implicit conversions from Object to Application'

hrrnativexcel.Cells(1, 1).value = "Time [s]" 'O.S. On disallows late binding'

For Each o As String In Form3.ListBox1.Items.Cast(Of Object).Zip(Form3.ListBox2.Items.Cast(Of Object), Function(x1, x2) x1 & "," & x2) 'O.S. On prohibits operands of type Object for operator &.'

我如何更改此行以解决此错误?谢谢大家会回答我。

4

1 回答 1

0

改变:

Label6.Text = FormatNumber(CInt(Form3.Label12.Text), "0.00") - O.S

至:

Label6.Text = CDbl(Form3.Label12.Text).ToString("0.00")

对于 Double to Integer 错误。

改变:

hrrspk.Add(Form3.ListBox2.Items(i))

至:

hrrspk.Add(CInt(Form3.ListBox2.Items(i)))

改变:

If Me.TextBox1.Text.Split(".")(1).Length < 3 Then

至:

If Me.TextBox1.Text.Split(".".ToCharArray())(1).Length < 3 Then

对于对象和 & 一,更改:

Function(x1, x2) x1 & "," & x2

至:

Function(x1, x2) CStr(x1) & "," & CStr(x2) ' or use x1.ToString() and x2.ToString()
于 2020-11-09T17:31:04.147 回答