Respected sir,
If we want to compute the summation of 1+2+3+4+……+100 in vb6 , what is the program to follow for that?
1
Expert's answer
2012-05-25T09:12:39-0400
VERSION 5.00 Begin VB.Form Form1 Caption = quot;Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth & = 4680 LinkTopic = quot;Form1" ScaleHeight & = 3090 ScaleWidth = 4680 StartUpPosition = 3& 'Windows Default Begin VB.CommandButton Command1 Caption = quot;Command1" Height = 975 Left = 960 TabIndex & = 0 Top = 840 Width & = 2415 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim count As Integer 'variable to hold result count = 0 For i = 1 To 100 'in this cycle we are adding values 1 to 100 to the resulting variable count = count + i Next i MsgBox (count) 'displaying result End Sub
Comments
Leave a comment