一道vb的题我写的程序是Public Class Form1 Subjiecheng(ByRef m%) Dimi%,n%,x% x = 1 Fori = 1 To n x = x * i Next m = x TextBox2.Text = m EndSub PrivateSub Button1_Click(ByValsender

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/25 14:58:56
一道vb的题我写的程序是Public Class Form1    Subjiecheng(ByRef m%)        Dimi%,n%,x%        x = 1        Fori = 1 To n            x = x * i        Next        m = x        TextBox2.Text = m    EndSub    PrivateSub Button1_Click(ByValsender
xW[OA+{i)[mIyQd/SOňh x(^lt_8۰n'7d̜3ߜ=~%VJGKBãkƣulvesmo L"5 P 3Z&d(f!o: Ȋ Pr w8=֪" dw,ꮭNIcGZd#59$˲4CkWu1c~JHNޞJ8ɻ-/ڲFQ|$+粪jBDT~Vx E4b94y$>E "(aD(0e aaQ&*ݐcY$u'6K'ƸDCĺ,,q cbLg8D"CA ӮtWoϮ*~ ծҠ<pHl&Ec1&YA7bK%6TЫMJ0E=l;g~p"7?u<憋Z("|NS~2#$ Y(NB N 19.\CAWs0@'`CAP&٣auNf}]r$w$#鴯HL;N>|_sJ Yb װDKNi&~m8i$]Zu_nጮ:h.r#j-p 5ZnfíK3u:g]}JQ?ϑ l9 nExsT{(Cs%EyՖ;q'؋u9bkq˔jS&glYKW`966v!1\ /7JaX/-^|Vk+]^;/coˬEhQs/AF

一道vb的题我写的程序是Public Class Form1 Subjiecheng(ByRef m%) Dimi%,n%,x% x = 1 Fori = 1 To n x = x * i Next m = x TextBox2.Text = m EndSub PrivateSub Button1_Click(ByValsender
一道vb的题

我写的程序是

Public Class Form1
    Subjiecheng(ByRef m%)
        Dimi%,n%,x%
        x = 1
        Fori = 1 To n
            x = x * i
        Next
        m = x
        TextBox2.Text = m
    EndSub
    PrivateSub Button1_Click(ByValsender As System.Object,ByVal e AsSystem.EventArgs) Handles Button1.Click
        Dimn%
        n = Val(TextBox1.Text)
        IfRadioButton1.Checked = True Then
            jiecheng(n)
        Else
            jiecheng(n + 2)
        EndIf
    EndSub
End Class
运行结果总出错求大神解答

一道vb的题我写的程序是Public Class Form1 Subjiecheng(ByRef m%) Dimi%,n%,x% x = 1 Fori = 1 To n x = x * i Next m = x TextBox2.Text = m EndSub PrivateSub Button1_Click(ByValsender
Public Class Form1

    Sub jiecheng(m%)
    
        Dim i%, n%, x%
    
        n = m

        x = 1

        For i = 1 To n

            x = x * i

        Next

        TextBox2.Text = x

    End Sub

    Private Sub Button1_Click(ByValsender As System.Object, ByVal e AsSystem.EventArgs) Handles Button1.Click

        Dim n%

        n = Val(TextBox1.Text)

        If RadioButton1.Checked = True Then

            jiecheng(n)

        Else

            jiecheng(n + 2)

        End If

    End Sub

End Class
试试,
最主要的问题在于 jiecheng 函数 没有取得 n 的值,反而跟一个不相关的变量 m 纠缠不清.