Question combobox problem

darkcat02

Active member
Joined
Mar 4, 2009
Messages
38
Programming Experience
1-3
i have this code to populate combobox... but my problem is.. i need to get those 2 values i put in the combobox... one it is selected...

Private Sub Fill_CBBookChapterVerse(ByVal ComboBox As ComboBox)

ComboBox.Items.Clear()

Dim dbFile As String
dbFile = strBibleDataPath & strBibleFilename
Dim cnndbFile As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" & _
dbFile & ";Mode=Read;Jet OLEDB:Database Password=" & strBiblePw(strBibleID))
cnndbFile.Open()

' Read "BibleList" Table
Dim BListSelectQuery As String = "SELECT a.BookNum, a.Chapter, a.Verse, b.BookStdName From BibleVerses a, BibleBooks b WHERE a.BookNum = b.BookNum"
Dim BListCommand As New OleDb.OleDbCommand(BListSelectQuery, cnndbFile)
Dim BListReader As OleDb.OleDbDataReader
BListReader = BListCommand.ExecuteReader()
Dim nCount As Integer
If BListReader.HasRows Then
ComboBox.Items.Add("Select Verse")
ComboBox.SelectedIndex = 0
Do While (BListReader.Read())
Dim Book, Chapter, Verse, ChapterVerse As String
Book = BListReader.GetValue(BListReader.GetOrdinal("BookStdName")).ToString
Chapter = BListReader.GetValue(BListReader.GetOrdinal("Chapter")).ToString
Verse = BListReader.GetValue(BListReader.GetOrdinal("Verse")).ToString
ChapterVerse = Book & " " & Chapter & ":" & Verse
ComboBox.Items.Add(ChapterVerse)
Loop
nBibleMax = nCount
BListReader.Close()
Else
'MsgBox("Error on BibleList")
'ProjDataErrorMsg &= "No bibles listed." & vbCrLf
End If

BListReader.Dispose()
cnndbFile.Close()
End Sub ' Fill Combo Box Book, Chapter, Verse

i need to get the chapter and verse... i dont know if there is any way... help...
 
Do something like:

Select Chapter from Database Where Name = CStr(Combobox1.selecteditem)
&
Select Verse from Database Where Name = CStr(Combobox1.selecteditem)
 
huh?? what i mean is if i select in the combobox "book 1:10" i need to get the "1" and "10".. since i didnt put any value when selected.. i didnt know how to get those value... coz i need those value to bind something whenever selected... i tried to think of MID function.. but it wont work coz it will depends on how long the values... because the book name length could be long or short... and also the chapter and verse... any ideas???
 
VB.NET:
        Dim strValue As String = "book 1:10"

        Dim intSpacePos As Integer = 0
        Dim intColonPos As Integer = 0

        intSpacePos = strValue.IndexOf(" ")
        intColonPos = strValue.IndexOf(":")

        Console.WriteLine("Book Name : {0}", _
                          strValue.Substring(0, intSpacePos))

        Console.WriteLine("Chapter : {0}", _
                          strValue.Substring(intSpacePos + 1, _
                                            (intColonPos - 1) - intSpacePos))

        Console.WriteLine("Verse : {0}", _
                          strValue.Substring(intColonPos + 1))

outputs:
Book Name : book
Chapter : 1
Verse : 10
 
Back
Top