一个简单VB语法问题
今天老师留了一道作业,如下:假设:
a="1,3,"
b="1,2,3,4,"
我要将b中与a相同的部分去掉赋给c
让c="2,4,"
给位大哥哥该怎么版呢?要快,明天还要脚作业
这样1,2,3,4的看的头昏
做个这样的吧,
已交学费学生(a)
所有学生(b)
没交学费的学生(c)
然后把 a b 进行比较,得到 a 里没有的名字,b里却有的名字,赋予给c
是不是这样理解?
Private Sub Command1_Click()
Dim a, b, y, c As String
Dim x
a = "1,2,"
b = "1,2,3,4,"
x = Split(a, ",")
For i = 0 To UBound(x)
y = x(i)
If InStr(1, b, x(i)) <> 0 Then
c = c + "," + x(i)
End If
Next
Debug.Print c
End Sub
运行通过
[此贴子已经被作者于2006-3-7 20:39:09编辑过]