当前位置:百问十四>百科知识>vb if else 语句

vb if else 语句

2024-08-07 12:56:25 编辑:join 浏览量:605

vb if else 语句

嵌套不对,改:

adodc2.CommandType = adCmdText

If Combo1.Text = "请选择" Then

MsgBox ("请选择!")

ElseIf Combo1.Text = "姓名" Then

adodc1.RecordSource = "select name,workno from works where name='" & Trim(Text2.Text) & "' "

adodc1.Refresh

Text1.Text = adodc1.Recordset.Fields(0)

a = adodc1.Recordset.Fields(1)

adodc2.RecordSource = "select workno,did,jb,jj,kouc,zuih=jb+jj-kouc from gongzi where workno='" & Trim(a) & "' "

adodc2.Refresh

If adodc2.Recordset.RecordCount > 0 Then

adodc2.Recordset.MoveFirst

For i = 0 To 5

If adodc2.Recordset.Fields(i) <> "" Then

Text(i).Text = adodc2.Recordset.Fields(i)

Else

Text(i).Text = ""

End If

Next i

end if

ElseIf Combo1.Text = "工作号" Then

adodc1.RecordSource = "select name from works where workno='" & Trim(Text2.Text) & "' "

adodc1.Refresh

Text1.Text = adodc1.Recordset.Fields(0)

adodc2.RecordSource = "select workno,did,jb,jj,kouc,zuih=jb+jj-kouc from gongzi where workno='" & Trim(Text2.Text) & "' "

adodc2.Refresh

If adodc2.Recordset.RecordCount > 0 Then

adodc2.Recordset.MoveFirst

For i = 0 To 5

If adodc2.Recordset.Fields(i) <> "" Then

Text(i).Text = adodc2.Recordset.Fields(i)

Else

Text(i).Text = ""

End If

Next i

End If

End If

镶嵌太多,可能不对称,建议改进程序

一层if end if就缩进 一点,这样才好检查

发代码的时候百度会屏蔽掉连续的空格的.

太乱.

标签:vb,else,语句

版权声明:文章由 百问十四 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.baiwen14.com/article/275470.html
热门文章