|
查看: 1118|回复: 9
|
vb + mysql
[复制链接]
|
|
|
|
想请问各位高手,如果说在一个form 里有5个选择(用checkbox),要是我只选了2 个,那要怎样把只选择的checkbox里的text 放进database 呢?如果是save为1/0 我知道怎样做,但如果要save checkbox里的text 呢,该怎样做? |
|
|
|
|
|
|
|
|
|
|
发表于 13-5-2008 01:38 PM
|
显示全部楼层
我不懂得vb,但是可以以泛用的programming来回答你。
一般上CheckBox会有这两个 property: CheckBox.Checked (数据类型通常是boolean) 和 CheckBox.Caption (数据类型通常是 String, 或者 char *)。
检查这5个CheckBox的 Checked,如果 CheckBox.Checked == true 就把该 CheckBox 的 CheckBox.Caption 写入 database. |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 13-5-2008 04:24 PM
|
显示全部楼层
|
我明白你的解释,但问题是如果我要把只选择的checkbox save 在同一个field 呢? 该如何做? |
|
|
|
|
|
|
|
|
|
|
发表于 13-5-2008 05:35 PM
|
显示全部楼层
|
就把所有checked = true的caption用string合起來啦 |
|
|
|
|
|
|
|
|
|
|
发表于 13-5-2008 09:49 PM
|
显示全部楼层
vb 6??
if check1.value=1 then
data1.recordset![field]=check1.caption
endif
.
.
.
.
.
.
. |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 14-5-2008 08:51 AM
|
显示全部楼层
原帖由 Fly_Fish 于 13-5-2008 09:49 PM 发表 
vb 6??
if check1.value=1 then
data1.recordset![field]=check1.caption
endif
.
.
.
.
.
.
.
如果是用这样的方法能把全部我所选的checkbox caption 都save 在同一个field 吗?
意识是说如果我有a, b, c, d, e 的check box 如果我只选a, c 要如何把a, c save 在同一个field? |
|
|
|
|
|
|
|
|
|
|
发表于 14-5-2008 11:46 AM
|
显示全部楼层
|
应该可以使用 a.Caption + c.Caption 吧? 我用惯C++,String 或者AnsiString 都可以使用 + operator 来 concatenate 的。 |
|
|
|
|
|
|
|
|
|
|
发表于 14-5-2008 11:32 PM
|
显示全部楼层
回复 6# albert_tky 的帖子
if check1.value=1 then
data1.recordset.edit
data1.recordset![field]=data1.recordset![field]&check1.caption
data1.recordset.update
endif |
|
|
|
|
|
|
|
|
|
|
发表于 15-5-2008 01:56 PM
|
显示全部楼层
Dim tempstr as String
tempstr =""
if check_A = 1 then
    tempstr = tempstr & check_A.Caption
endif
if check_B = 1 then
    tempstr = tempstr & check_B.Caption
endif
if check_C = 1 then
    tempstr = tempstr & check_C.Caption
endif
if check_D = 1 then
    tempstr = tempstr & check_D.Caption
endif
data1.recordset.edit
data1.recordset![field]=tempstr
data1.recordset.update
[ 本帖最后由 水瓶座的小飞侠 于 15-5-2008 01:58 PM 编辑 ] |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 15-5-2008 02:22 PM
|
显示全部楼层
决解了!我用了这方法。。。
rsql!item_receive = item_receive
rsql.Update
data1.recordset.edit <----这个不用写
谢谢你们的帮忙! |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|