佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1119|回复: 9

vb + mysql

[复制链接]
发表于 13-5-2008 09:46 AM | 显示全部楼层 |阅读模式
想请问各位高手,如果说在一个form 里有5个选择(用checkbox),要是我只选了2 个,那要怎样把只选择的checkbox里的text 放进database 呢?如果是save为1/0 我知道怎样做,但如果要save checkbox里的text 呢,该怎样做?
回复

使用道具 举报


ADVERTISEMENT

发表于 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?
回复

使用道具 举报

Follow Us
发表于 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
回复

使用道具 举报


ADVERTISEMENT

发表于 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 <----这个不用写

谢谢你们的帮忙!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 28-12-2025 02:26 AM , Processed in 0.124154 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表