还是报错:红色代码肯定不对,上面的代码出来的表达式只能是字符,字符如何能计算,把表达转换为能计算的表达式如何实现?
.NET Framework 版本:4.0.30319.18063
Foxtable 版本:2021.12.30.1
错误所在事件:窗口,窗口1,Button1,Click
详细错误信息:
Conversion from string "11'+'" to type 'Long' is not valid.
Input string was not in a correct format.
Dim bds As Integer
Dim zu As String
Dim Names() As Integer = {11,12,13,14,15,16,17,18,19}
Dim s1 As New List(of Integer)
Dim s2 As New List(of Integer)
s1.AddRange(Names) '将数组中的元素全部加入到集合中
s2.AddRange(s1) '将集合s1中的元素全部加入到集合s2中
Dim fh() As String = {"+","-","*","/"}
Dim t1 As New List(of String)
Dim t2 As New List(of String)
t1.AddRange(fh) '将数组中的元素全部加入到集合中
t2.AddRange(t1) '将集合s1中的元素全部加入到集合s2中
For i As Integer = 0 To s2.count -1
For c As Integer = 0 To t2.count -1
zu = s2(i) & "'" & t2(c) & "'" Or "(" & s2(i) & "'" & t2(c) & "'"
Next
s2.RemoveAt(i)
For i2 As Integer = 0 To s2.count - 1
For c As Integer = 0 To t2.count -1
If zu Like "(*" Then
zu = zu & s2(i2) & ") '" & t2(c) & "'" And zu & s2(i2) & "'" & t2(c) & "'"
Else
zu = zu & s2(i2) & "'" & t2(c) & "'" And zu & "' (" & s2(i2) & "'" & t2(c)
End If
Next
s2.RemoveAt(i2)
For i3 As Integer = 0 To s2.count - 1
For c As Integer = 0 To t2.count -1
Dim u As Integer = 0
Dim u1 As Integer = 0
For x As Integer = 1 To 100
If zu.lastindexof("(")> zu.indexof("(")
zu = zu.Substring(0,zu.lastindexof("("))
u = u + 1
End If
If zu.lastindexof("(") = zu.indexof("(") Then
Exit For
End If
If zu.lastindexof(")")> zu.indexof(")")
zu = zu.Substring(0,zu.lastindexof(")"))
u1 = u1 + 1
End If
If zu.lastindexof(")") = zu.indexof(")") Then
Exit For
End If
Next
If zu Like "(*" And (u + 1) Mod 2 = 0 And (u1 + 1) Mod 2 = 0 Then
zu = zu & s2(i2) & "'" & t2(c) & "'" Or zu & s2(i2) & "'" & t2(c) & "' ("
ElseIf zu Like "(*" And (u + 1) Mod 2 = 1 And (u1 + 1) Mod 2 = 0 Then
zu = zu & s2(i2) & "'" & t2(c) & "'" Or zu & s2(i2) & "'" & t2(c) & "' )"
End If
Next
s2.RemoveAt(i3)
Next
Next
DataTables("表A").StopRedraw
For Each dr As DataRow In DataTables("表A").DataRows
If CDbl(zu) = 2022 Then
dr = DataTables("表A").AddNew
dr("表达式") = zu
End If
Next
DataTables("表A").ResumeRedraw
Next