首页 > Linux操作系统 > Linux操作系统 > FP项目技术收获总结
For IntI = grdDetail.Rows - 1 To 0 Step -1
If Trim(grdDetail.Columns("flag").CellText(IntI)) = "E" Then
Exit For
Else
If Len(Trim(grdDetail.Columns("Part Number").CellText(IntI))) = 0 Then
Screen.MousePointer = vbDefault
MsgBox "the 'Part Number' column is not nullable!", vbInformation, "Information Message:"
grdDetail.SelBookmarks.Add grdDetail.AddItemBookmark(IntI)
Exit Sub
ElseIf Len(Trim(grdDetail.Columns("Quantity").CellText(IntI))) = 0 Then
Screen.MousePointer = vbDefault
MsgBox "the 'Quantity' column is not nullable!", vbInformation, "Information Message:"
grdDetail.SelBookmarks.Add grdDetail.AddItemBookmark(IntI)
Exit Sub
End If
End If
Next IntI
5、在BeforeColUpdate事件中check数据不符合格式提示出错后,将焦点定位到出错位置,先MsgBox,再Cancel= 1,最后Call SetGridFocus;
Case "Quantity"
If Len(Trim(grdDetail.Columns("Quantity").Text)) = 0 Then
MsgBox "Quantity column is not nullable!", vbInformation, "Information Message:"
Cancel = 1
Call SetGridFocus(grdDetail, grdDetail.AddItemRowIndex(grdDetail.Bookmark) + 1, ColIndex + 1, 0)
Exit Sub
End If
'********************************************************************
'* Input : grdObject->SSDBGrid,IntRow->Currrent Row ID,intCol->Next Column,intLockUnVis->Locked Number
'* Output :
'* Process Flow :
'********************************************************************
Private Sub SetGridFocus(grdObject As SSDBGrid, intRow As Long, intCol As Long, intLockUnVis As Long)
grdObject.SetFocus
SendKeys "^{HOME}{DOWN " & intRow & "}{RIGHT " & Abs(intCol - intLockUnVis) & "}", True
grdObject.ActiveCell.SelStart = 0
grdObject.ActiveCell.SelLength = Len(grdObject.ActiveCell.Text)
End Sub
6、SQL语句中WHERE条件的顺序
在SQL语句中WHERE后的条件是从后向前执行的,所以为提高SQL语句的执行效率,应该把能过滤掉较多记录的条件写在后边,这样在执行前面的条件时需要操作的记录数就会少很多,效率自然会有所提高。
7、Error处理
在相对复杂或有对数据库进行操作的函数里都应该有Error处理代码;在函数级Error处理代码中应该Call Err.Raise(Err.Number, "getFileFromRemote", Err.Description)将Error向上抛;在UI级Error处理中应该Call ShowError直接将错误信息发给用户;在函数中有对数据库进行操作的代码,在Error处理时都应该Set rsDB = Nothing来释放资源。
8、FP中FTP实现
相关内容可参考FP FTP help.doc;
9、在一个Form中MsgBox尽量风格一致;
如:MsgBox "the file can't be found!", vbInformation, "Information Message:"
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/11411056/viewspace-734283/ ,如需转载,请注明出处,否则将追究法律责任。