找到原因了
Dim mq As String = Tables("窗口1_Table1").Current("单据")
Dim pm As String = Tables("窗口1_Table1").Current("顺序")
Dim Res As DialogResult
If Tables("窗口1_Table1").Current Is Nothing Then
MessageBox.Show("没有选取删除数据行!", "提示", MessageBoxButtons.ok, MessageBoxIcon.Question)
Else
Res = MessageBox.Show("是否删除【顺序:"& pm &" 单据:"& mq &"】?", "提示", MessageBoxButtons.yesno, MessageBoxIcon.Question)
If Res = DialogResult.yes Then
Tables("窗口1_Table1").Current.Delete
DataTables("窗口1_Table1").Save()
End If
End If
会出运行错误
If Tables("窗口1_Table1").Current Is Nothing Then
MessageBox.Show("没有选取删除数据行!", "提示", MessageBoxButtons.ok, MessageBoxIcon.Question)
Else
Dim mq As String = Tables("窗口1_Table1").Current("单据")
Dim pm As String = Tables("窗口1_Table1").Current("顺序")
Dim Res As DialogResult
Res = MessageBox.Show("是否删除【顺序:"& pm &" 单据:"& mq &"】?", "提示", MessageBoxButtons.yesno, MessageBoxIcon.Question)
If Res = DialogResult.yes Then
Tables("窗口1_Table1").Current.Delete
DataTables("窗口1_Table1").Save()
End If
End If
把定义变量放IF里面就不会出错
找到原因了
Dim mq As String = Tables("窗口1_Table1").Current("单据")
Dim pm As String = Tables("窗口1_Table1").Current("顺序")
Dim Res As DialogResult
If Tables("窗口1_Table1").Current Is Nothing Then
MessageBox.Show("没有选取删除数据行!", "提示", MessageBoxButtons.ok, MessageBoxIcon.Question)
Else
Res = MessageBox.Show("是否删除【顺序:"& pm &" 单据:"& mq &"】?", "提示", MessageBoxButtons.yesno, MessageBoxIcon.Question)
If Res = DialogResult.yes Then
Tables("窗口1_Table1").Current.Delete
DataTables("窗口1_Table1").Save()
End If
End If
表没有数据会出运行错误
If Tables("窗口1_Table1").Current Is Nothing Then
MessageBox.Show("没有选取删除数据行!", "提示", MessageBoxButtons.ok, MessageBoxIcon.Question)
Else
Dim mq As String = Tables("窗口1_Table1").Current("单据")
Dim pm As String = Tables("窗口1_Table1").Current("顺序")
Dim Res As DialogResult
Res = MessageBox.Show("是否删除【顺序:"& pm &" 单据:"& mq &"】?", "提示", MessageBoxButtons.yesno, MessageBoxIcon.Question)
If Res = DialogResult.yes Then
Tables("窗口1_Table1").Current.Delete
DataTables("窗口1_Table1").Save()
End If
End If
把定义变量放IF里面就不会出错