例如在cmdCommandButton1_Click()檢查Text1.Text是否和其他多個TextBox相同
If Text1.Text = Text2.Text Then
  MsgBox "輸入錯誤", vbCritical, App.Title
  Text1.SelStart = 0
  Text1.SelLength = Text1.Text
  Text1.SetFocus
 End If
 If Text1.Text = Text3.Text Then
  MsgBox "輸入錯誤", vbCritical, App.Title
  Text1.SelStart = 0
  Text1.SelLength = Text1.Text
  Text1.SetFocus
 End If
 If Text1.Text = Text4.Text Then
  MsgBox "輸入錯誤", vbCritical, App.Title
  Text1.SelStart = 0
  Text1.SelLength = Text1.Text
  Text1.SetFocus
 End If
if 和 ListBox比較錯誤
  MsgBox "輸入錯誤", vbCritical, App.Title
  Text1.SelStart = 0
  Text1.SelLength = Text1.Text
  Text1.SetFocus
 End If
等等.
ErrHandler
MsgBox "輸入錯誤", vbCritical, App.Title
  Text1.SelStart = 0
  Text1.SelLength = Text1.Text
  Text1.SetFocus
End Sub
請問這些相同之處理如何在該事件程序內用類似模組方式處理?不知只限於該事件程序自己用的[事件程序模組]該如何寫?
arrow
arrow
    全站熱搜

    vbqa 發表在 痞客邦 留言(7) 人氣()