这样?
Dim cz As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim jjk As WinForm.TextBox = e.Form.Controls("TextBox6")
Dim fs As WinForm.ComboBox = e.Form.Controls("ComboBox2")
If cz.text = "" Then
MessageBox.show("请先选择材质","提示")
Else
If fs.text = "横裁" Then
Dim maxc As Integer
Dim maxk As Integer
maxc = DataTables("规格需求").Compute("max(长)","材质 ='" & cz.text & "' and 剩余欠量 > 0 and 不套裁 = false")
maxk = DataTables("规格需求").Compute("max(宽)","长 = "& maxc &" And 剩余欠量 > 0 And 不套裁 = false")
Dim dc As DataRow = DataTables("规格需求").find("长 = "& maxc &" And 宽 = "& maxk &"")
Dim gg1 As String = maxc & "*" & maxk
Dim x1 As Integer = maxc / 3.5
Dim x2 As Integer = maxk / 3.5
Dim wzx As Integer = 5 + (i - 1) * (maxc + 1)
Dim xq As Integer = dc("剩余欠量")
Dim hengchu1 As Integer = Int(1200 / (maxk + 4))
Dim Ary() As Integer = {xq,hengchu1}
Array.Sort(ary)
Dim sas As Integer = ary(0)
Dim Panel1 As WinForm.Panel
Dim lbl As WinForm.Label
For i As Integer = 1 To sas
Panel1 = e.Form.CreateControl("Panel" & i, ControlTypeEnum.Panel)
Panel1.SetBounds(wzx, 5, x2, x1)
e.Form.Controls("SplitContainer1").Panel2.AddControl(Panel1)
e.Form.Controls("Panel1").BackColor = Color.Orangered
lbl = e.Form.CreateControl("Label" & i, ControlTypeEnum.Label)
lbl.Text = gg1
lbl.Left = x2 / 2 - 30
lbl.Top = x1 / 2 - 15
e.Form.Controls("Panel1").AddControl(lbl)
Dim nd As DataRow = DataTables("临时").addnew()
nd("规格编号") = dc("规格编号")
nd("数量") = 1
'Dim syh1 As Integer = 1
Next
End If
End If