# Re: 有关传值的问题

Posted by Windows NT user on March 06, 1999 at 12:20:45:

In Reply to: 有关传值的问题 posted by Tim on March 06, 1999 at 11:05:35:

: 请教一个简单的问题

: 就是有关传值的问题
: 为什么 程式执行到 Ascan 后 Text2.text 列出来的值 不是 "老人高兴!!" 而只
: 有 显示 "老人" 两个字呢??
: 假设 Text1.text="老人"

: 在vb是不是不能回传字串 呢?? 谢谢~~
Option Explicit
Dim a() As String, strtt As String, strCi As String, strArray As String, strTxt As String, strC2 As String
Dim ReturnV As Integer, intCc As Integer, intaa As Integer
Dim i As Long
Private Sub Command1_Click()
Dim inttx As Integer
strTxt = Text1.Text

Ascan strTxt
Text2.Text = strTxt
Print strCi
inttx = 5
data inttx
Text4.Text = inttx

End Sub

Private Sub Form_Load()

ReDim a(6)
a(0) = "女"
a(1) = "男"
a(2) = "老人"
a(3) = "小孩"
a(4) = "动物"
a(5) = "狗"

For i = 1 To 5
List1.AddItem a(i - 1)
Next i

End Sub

Public Sub Ascan(strCi As String)
For i = LBound(a) To UBound(a)
If a(i) = strCi Then
intaa = i
Text3.Text = intaa
strCi = strCi + "高兴 !!"
Exit For
End If
Next i
End Sub

Public Sub data(intCc As Integer)
intCc = intCc * intCc
End Sub

Private Sub List1_Click()
Text1.Text = List1.Text
End Sub

: 程式如下~~

: Dim a(), strtt, strCi, strArray, strTxt, strC2 As String
: Dim ReturnV, intCc, intaa As Integer

: Private Sub Command1_Click()
: Dim inttx As Integer
: strTxt = Text1.Text

: Ascan strTxt
: Text2.Text = strTxt
: Print strCi
: inttx = 5
: data inttx
: Text4.Text = inttx
:
: End Sub

: Private Sub Form_Load()

:
: ReDim a(6)
: a(0) = "女"
: a(1) = "男"
: a(2) = "老人"
: a(3) = "小孩"
: a(4) = "动物"
: a(5) = "狗"
:
: For i = 1 To 5
: List1.AddItem a(i - 1)
: Next i

: End Sub

:
: Public Sub Ascan(strCi As String)
: For i = LBound(a) To UBound(a)
: If a(i) = strCi Then
: intaa = i
: Text3.Text = intaa
: strCi = strCi + "高兴 !!"
: Exit For
: End If
: Next i
: End Sub

: Public Sub data(intCc As Integer)
: intCc = intCc * intCc
: End Sub

: Private Sub List1_Click()
: Text1.Text = List1.Text
: End Sub

Follow Ups: