I'm developing a correspondence app. using VB.NET. So, I have a CheckedListBox that fills in with items once its parent form shows up, and its item collection is derived from a specific column within a table in a database via an SQL code.
So, assuming that I have filled in all required data in that form, and clicked the save button, it would save all checked items' text to the new row. However, I need to save another text other than mentioned in that CheckedListBox. Let's say it is (the text I want to save to that new row) a text mentioned in the same table, but in a different column. Here is the code I have used just to assure that I'm good to a certain point.
Since a week, and until now, I've been stock with that code.
Actually, I have tried some codes of the While..End While and Do While..Loop for the sake of changing the Str in the MessageBox with the column rows I want, but no one worked.
Try
Dim Str As String = ""
If (checkedListBox1.CheckedItems.Count > 0) Then
Dim i As Integer = 0
Do While (i < checkedListBox1.CheckedItems.Count)
If (Str = "") Then
Str = checkedListBox1.CheckedItems(i).ToString
label1.Text = Str
Else
Str = (Str + (", " + checkedListBox1.CheckedItems(i).ToString))
label1.Text = Str
End If
i = (i + 1)
Loop
' Make your connection to the DataBase and insertion code starting within that area.
MessageBox.Show(("Your selection is for : " + Str))
Else
MessageBox.Show("Please select one name at least to work it out!")
End If
'While (checkedListBox1.CheckedItems.Count > 0)
'checkedListBox1.SetItemChecked(checkedListBox1.CheckedIndices(0), false)
'End While
Catch ex As Exception MessageBox.Show((ex.Message + ex.ToString)) End Try