比较菜的问题,但我有难度!!

fuke 2003-05-08 09:47:55
dim str as string
dim code(2)as string
dim index_code as long
 code(0)="+"
code(1)="-"
code(2)="*"
for index_code=0 to 2 step 1
str="3" & code &"4"
....
next index_code
问题:请问如何得到"3" & code & "4"的数字值
...全文
66 点赞 收藏 9
写回复
9 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
IwantFlay 2003-05-08
for index_code=0 to 2 step 1
str=str & code(index_code)
next index_code

str="3" & str & "4"
回复
CityhunterID 2003-05-08
同意楼上的说
回复
sikeen 2003-05-08
dim str as string
dim code(2)as string
dim index_code as long
code(0)="+"
code(1)="-"
code(2)="*"
str = "0"

for index_code=0 to 2 step 1
select case code(index_code)
case "+"
str = cstr(cdbl(str) + 3 + 4)
case "-"
str = cstr(cdbl(str) + 3 - 4)
case "*"
str = cstr(cdbl(str) + 3 * 4)
end select

....
next index_code
回复
stiffe01 2003-05-08
本身用str作变量就错了!
回复
CloneCenter 2003-05-08
str=val(3 code(index_code) 4)
这样也可以???

怎么感觉楼上似乎是个 MM?
回复
jianglifen 2003-05-08
取出str的值,不过我觉得你用字符型str的值变成 34了,而不是3+4=7的值

dim str as interger
str=val(3 code(index_code) 4)
回复
lihonggen0 2003-05-08
Dim str As String
Dim num As Double
Dim code(2) As String
Dim index_code As Long
code(0) = "+"
code(1) = "-"
code(2) = "*"
For index_code = 0 To 2 Step 1
Select Case code(0)
Case "+"
num = Val("3") + Val("4")
Case "-"
num = Val("3") - Val("4")
Case "*"
num = Val("3") * Val("4")
End Select
Next index_code
回复
lihonggen0 2003-05-08
Dim str As String
Dim num As Double
Dim code(2) As String
Dim index_code As Long
code(0) = "+"
code(1) = "-"
code(2) = "*"
For index_code = 0 To 2 Step 1
Select Case code(0)
Case "+"
num = Val("3") + Val("4")
Case "-"
num = Val("3") - Val("4")
Case "*"
num = Val("3") * Val("4")
End Select
Next index_code
回复
jaek999 2003-05-08
dim str as string
dim code(2)as string
dim index_code as long
 code(0)="+"
code(1)="-"
code(2)="*"
for index_code= 0 to 2
select case code(index_code)
case "+"
str=cstr$(3+4)
case "-"
str=cstr$(3-4)
case "*"
str=cstr$(3*4)
end select
next index_code
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7491

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2003-05-08 09:47
社区公告
暂无公告