Public Sub ResetCombobox(ByRef cmbA As ComboBox,Optional cmbB As ComboBox,Optional cmbC As ComboBox)
If cmbA.Items.Count > 0 Then
cmbA.Items.Clear()
End If
If cmbB.Items.Count > 0 Then
cmbB.Items.Clear()
End If
If cmbC.Items.Count > 0 Then
cmbC.Items.Clear()
End If
End Sub
Byref และ Byval แตกต่างกันในกรณีไหนบ้างครับ ?
ตอนนี้ที่ Error List มันขึ้น
Error 17 Optional parameters must specify a default value. ต้องระบุ Default อย่างไรครับ? ในกรณีนี้
Tag : .NET, Ms SQL Server 2008, Win (Windows App), VS 2008 (.NET 3.x)
Private Sub LookupIssueTypeBy(ByVal str_JobtypeCode As String)
If ds.Tables.Contains("ds_IssueType") = True Then
ds.Tables("ds_IssueType").Clear()
End If
strSQL = ""
strSQL = "select issueTypecode,issueTypeDesc from tblissueType where jobtypeID='" & str_JobtypeCode & "' or jobtypeID='00' order by issueTypeCode ASC"
da = New SqlDataAdapter(strSQL, Cn)
da.Fill(ds, "ds_Issuetype")
If ds.Tables("ds_Issuetype").Rows.Count <> 0 Then
With cmbIssueType
.DataSource = ds.Tables("ds_Issuetype")
.ValueMember = "IssueTypecode"
.DisplayMember = "IssueTypedesc"
.SelectedIndex = 0
End With
End If
End Sub
Private Sub LookupIssueSystemBy(ByVal str_IssuetypeCode As String)
If ds.Tables.Contains("ds_IssueSystem") = True Then
ds.Tables("ds_IssueSystem").Clear()
End If
strSQL = ""
strSQL = "select sysCode,sysDesc from tblissueSystem where issuetypeCode='" & str_IssuetypeCode & "' or issuetypeCode='00' order by sysCode ASC"
da = New SqlDataAdapter(strSQL, Cn)
If ds.Tables("ds_IssueSystem").Rows.Count <> 0 Then
With cmbissueSystem
.DataSource = ds.Tables("ds_IssueSystem")
.ValueMember = "syscode"
.DisplayMember = "sysdesc"
.SelectedIndex = 0
End With
End If
End Sub
Private Sub LookupIssueTopicBy(ByVal str_sysCode As String)
If ds.Tables.Contains("ds_IssueTopic") = True Then
ds.Tables("ds_IssueTopic").Clear()
End If
strSQL = ""
strSQL = "select TopicCode,TopicDesc from tblissueTopic where sysCode='" & str_sysCode & "' or sysCode='00' order by topicCode ASC"
da = New SqlDataAdapter(strSQL, Cn)
If ds.Tables("ds_IssueTopic").Rows.Count <> 0 Then
With cmbIssueTopic
.DataSource = ds.Tables("ds_IssueTopic")
.ValueMember = "Topiccode"
.DisplayMember = "Topicdesc"
.SelectedIndex = 0
End With
End If
End Sub
Private Sub cmbIssueType_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbIssueType.SelectedIndexChanged
LookupIssueSystemBy(cmbIssueType.SelectedValue.ToString)
End Sub
Private Sub cmbJobtype_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbJobtype.SelectedIndexChanged
LookupIssueTypeBy(cmbJobtype.SelectedValue.ToString)
End Sub
Private Sub cmbissueSystem_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbissueSystem.SelectedIndexChanged
LookupIssueTopicBy(cmbissueSystem.SelectedValue.ToString)
End Sub