الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

Problem With The Code

مغلق
بدأه adeeb في 23 يوليو 2002 · 2 رد · 539 مشاهدة · في لغة Ms Visual Basic 6 وما قبلها من إصدارات
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

I HAVE A PROBLEM WITH THIS CODE I DO NOT KNOW WHY THE SUM AND THE AVG VARIABLE DOES NOT WORK

HERE IS THE CODE

Private Sub Command1_Click()

Dim sum As Double, avg As Double

If Command1.Caption = "New Data Set" Then

vCount = InputBox("how many values do you want to enter")

If Not IsNumeric(vCount) Then

MsgBox "Please enter a numeric data"

Exit Sub

End If

For i = 1 To vCount

Load Label1(i)

Load Text1(i)

Label1(i).Top = Label1(i - 1).Top + 1.25 * Label1(i).Height

Text1(i).Top = Text1(i - 1).Top + 1.25 * Text1(i).Height

Label1(i).Visible = True

Text1(i).Visible = True

Label1(i).Caption = "Value# " & i

Next

Me.Height = Text1(vCount).Top + 2.5 * Text1(vCount).Height

Command1.Caption = "Calculate Data now"

Else

For i = 1 To vCount 'the variable vCount is not passed to this statement?

If IsNumeric(Text1(i).Text) Then

sum = sum + Text1(i)

End If

Next

avg = sum / vCount ' the variable vCount is not passed to this statement?

MsgBox "the average is & avg"

For i = 1 To vCount

Unload Label1(i)

Unload Text1(i)

Next

Me.Height = 2000

Command1.Caption = "New Data Set"

End If

End Sub

#2
Private Sub Command1_Click()

Dim sum As Double, avg As Double
Static vCount As Integer
If Command1.Caption = "New Data Set" Then
    vCount = InputBox("how many values do you want to enter")
    If Not IsNumeric(vCount) Then
        MsgBox "Please enter a numeric data"
        Exit Sub
    End If
    For i = 1 To vCount
        Load Label1(i)
        Load Text1(i)
        Label1(i).Top = Label1(i - 1).Top + 1.25 * Label1(i).Height
        Text1(i).Top = Text1(i - 1).Top + 1.25 * Text1(i).Height
        Label1(i).Visible = True
        Text1(i).Visible = True
        Label1(i).Caption = "Value# " & i
    Next
    Me.Height = Text1(vCount).Top + 2.5 * Text1(vCount).Height
    Command1.Caption = "Calculate Data now"
ElseIf Command1.Caption = "Calculate Data now" Then
    For i = 0 To vCount 'the variable vCount is not passed to this statement?
        If IsNumeric(Text1(i).Text) Then
            sum = sum + Text1(i)
        End If
    Next
    avg = sum / (vCount + 1) ' the variable vCount is not passed to this statement?
    MsgBox "the average is   " & avg
    For i = 1 To vCount
        Unload Label1(i)
        Unload Text1(i)
    Next
    Me.Height = 2000
    Command1.Caption = "New Data Set"
End If
End Sub
#3

brother ramadan I do not know how to say thank you really

my thanks to you will be a prayer for God to reward you with his mercy ,

about the code was the problem because I did not declare the vcount variable? thank you again

by the way i sent you a comment about the lessons in the Ado where the links does not work I hope that you read them?

هذا الموضوع مغلق.

مواضيع مشابهة