编一子过程MaxLength,在字符串s中,找出最长单词。编程可以运行,但点击确定键达不到效果。
1个回答
展开全部
Private Sub Maxlength(ByVal S As String, ByRef MaxWord As String)
MaxWord = ""
Dim words As String()
words = S.Split(" ")
For i As Integer = 0 To words.Length - 1
If words(i).Length > MaxWord.Length Then
MaxWord = words(i)
End If
Next
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim f As String = String.Empty
Call Maxlength(TextBox1.Text, f)
TextBox2.Text = f
End Sub
你写的处理方法,没有回传值(成了值传递,不是地址传递)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询