Ho valorizzato dei combo con questa funzione
Public Function FCaricaCombo()
Dim sql As String
Dim hres As Result
Dim hret As Result
Dim hreu As Result
With MSysCont.$hConn
.Type = "sqlite3"
.Host = MSysCont.sPercorso
MSysCont.pConnetti()
sql = "SELECT id, ragsociale FROM fornitori ORDER BY ragsociale;"
hres = .Exec(sql)
ComboBox1.Clear
For Each hres
ComboBox1.Add(hres!ragsociale, hres!id)
Next
MSysCont.pDisconnetti()
.Type = "sqlite3"
.Host = MSysCont.sPercorso
MSysCont.pConnetti()
sql = "SELECT id, codice, descrizione FROM codiva ORDER BY codice;"
hret = .Exec(sql)
ComboBox2.Clear
ComboBox4.Clear
ComboBox6.Clear
ComboBox8.Clear
For Each hret
ComboBox2.Add(hret!codice & " - " & hret!descrizione, hret!id)
ComboBox4.Add(hret!codice & " - " & hret!descrizione, hret!id)
ComboBox6.Add(hret!codice & " - " & hret!descrizione, hret!id)
ComboBox8.Add(hret!codice & " - " & hret!descrizione, hret!id)
Next
MSysCont.pDisconnetti()
.Type = "sqlite3"
.Host = MSysCont.sPercorso
MSysCont.pConnetti()
sql = "SELECT id, codice, conto FROM conti WHERE livello = 3 AND tipo = 2 ORDER BY codice;"
hreu = .Exec(sql)
ComboBox3.Clear
ComboBox5.Clear
ComboBox7.Clear
ComboBox9.Clear
For Each hreu
ComboBox3.Add(hreu!codice & " - " & hreu!conto, hreu!id)
ComboBox5.Add(hreu!codice & " - " & hreu!conto, hreu!id)
ComboBox7.Add(hreu!codice & " - " & hreu!conto, hreu!id)
ComboBox9.Add(hreu!codice & " - " & hreu!conto, hreu!id)
Next
MSysCont.pDisconnetti()
End With
End
Come potete vedere definisco sia il text che l'index, quando poi faccio la lettura con questo codice:
Public Sub ComboBox3_Click()
Dim sql As String
Dim hres As Result
Dim iRis As Integer
If bOp > 0 Then
With MSysCont.$hConn
.Type = "sqlite3"
.Host = MSysCont.sPercorso
MSysCont.pConnetti()
sql = "SELECT * FROM conti WHERE id = " & ComboBox3.Index & ";"
hres = .Exec(sql)
If hres.Available = True Then
Message.Info(hres.conto)
Label15.Text = hres!conto
Endif
MSysCont.pDisconnetti()
End With
dTotPar = dTotPar + fTot[0]
TextBox24.Text = Format(dTotPar, "#.#0")
If dTotDoc = dTotPar Then
iRis = Message.Question("Il totale del documento è stato raggiunto. Chiudo il documento?", "Si", "No")
If iRis = 1 Then
' fSalvaDoc()
Else
TextBox15.SetFocus
Endif
Else
TextBox15.SetFocus
Endif
Endif
End
non mi trova niente.
Perchè??? :hatecomputer:
La guida di Gambas dice:
ComboBox.Add (gb.qt4)
SUB Add ( Item AS String [ , Index AS Integer ] )
Inserts an element in the popup list box.
If Index is specified, then the new item is inserted at the Index position, 0 being the first item.
If Index is not specified, the new item is inserted at the end of the list.
Da come capisco, se inserisco il valore Index, sono io che lo difinisco. Mentre invece se non lo specifico viene inserito in maniera progressiva.
Sbaglio? :(