如何在vb 08中填充组合框 [英] How do I populate a combo box in vb 08

查看:63
本文介绍了如何在vb 08中填充组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计我真的很新,但是我需要用访问数据库来填充我的组合框,因为我正在尝试制作一个便宜的小结账系统而且它似乎不想工作。

如果有人可以帮我编写我的组合框并解释它是如何工作的,那将是惊人的,因为我需要能够单独选择每一个以便能够在技术上进行查询以搜索项目并从数据库中获取价格并且能够得到改变等。



如果任何人都可以帮助你做得很好。

Hey guys I'm really new to this but I need to populate my combo box's with an access data base as i am trying to make a cheap little checkout system and it doesnt seem to want to work.
If anyone could help me code my combo box and explain how it works would be amazing as I need to be able to individually select each one to be able to technically make a query to search for items and get a price from the db and being able to get change etc.

IF ANYONE COULD HELP THAT WOULD BE GREAT.

推荐答案

试试这个...



try this...

    Public Sub FillCombo(ByVal combo As ComboBox, ByVal sSQL As String, ByVal sTable As String, ByVal sNum As Integer)
        Dim totalRow As Long = 0

        Dim da As New OleDb.OleDbDataAdapter(sSQL, con)
        Dim ds As New DataSet
        Dim i As Integer
dim totalRow as integer
        ds = New DataSet()
        da.Fill(ds, sTable)
        totalRow = ds.Tables(sTable).Rows.Count - 1
        combo.Items.Clear()
        For i = 0 To totalRow
            combo.Items.Add("" & ds.Tables(sTable).Rows(i).ItemArray.GetValue(0).ToString())
        Next
        If (combo.Items.Count > 0) Then combo.SelectedIndex = 0
        If sNum = 1 Then combo.Items.Add("ALL")
    End Sub 


这篇关于如何在vb 08中填充组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆