Private Sub Command1_Click()
For a = -5 To 5
 b = a * a
 If b = 25 Then Text1.Text = a
 Text1.Text = a
Next
End Sub

解决方案 »

  1.   

    汗……那是你text1的问题了,你没写好。结果是后一个把前一个数据给覆盖掉了。应该为:
    Private Sub Command1_Click()
    For a = -5 To 5
     b = a * a
     If b = 25 Then Text1.Text = a
     Text1.Text =Text1.Text & a & vbcrlf
    Next
    End Sub
      

  2.   

    Private Sub Command1_Click()
    For a = 1 To 5
     b = a * a
     If b = 25 Then 
        Text1.Text = a
         exit for
      end if
    Next
    End Sub
      

  3.   

    Private Sub Command1_Click()
        Dim a as Long,b as long
        
        Text1.Text=""
        For a = -5 To 5
            b = a * a
            if b = 25 Then
                Text1.Text =Text1.Text & a & vbcrlf
            End If
        Next
        
    End Sub
      

  4.   

    你干吗不用两个TEXTBOX呢,要知道开方的结果本身就有一对数值,一个正值一个负值,这样不更好:
    Private Sub Command1_Click()
        Dim a as Long,b as long
        
        For a = 1 To 5
            b = a * a
            if b = 25 Then
                Text1.Text = a &  "-" & a
            End If
        Next
        
    End Sub
      

  5.   

    TO GetWindowPos(白痴) :
    得出两个5不又没错啊??
    负数相乘为正。这个基本道理你难道!?!?!?不知道吗??
    我倒。。