0% found this document useful (0 votes)
24 views1 page

GGGG

This VB code defines a form with two command buttons. When command button 1 is clicked, it prompts the user for a number and stores it in the variable n. When command button 2 is clicked, it uses a While loop to check if n is divisible by numbers from 2 to n, sums all the divisors, and displays the sum in a message box.

Uploaded by

Dan Vlad
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

GGGG

This VB code defines a form with two command buttons. When command button 1 is clicked, it prompts the user for a number and stores it in the variable n. When command button 2 is clicked, it uses a While loop to check if n is divisible by numbers from 2 to n, sums all the divisors, and displays the sum in a message box.

Uploaded by

Dan Vlad
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Option Strict Off Option Explicit On Friend Class Form1 Inherits System.Windows.Forms.

Form Dim n As Integer Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click n = Val(InputBox("introduceti numarul")) End Sub Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click Dim ok As Boolean Dim i As Integer Dim S As Integer Dim div As Integer div = 2 S = 0 While n <> 1 If n Mod div = 0 Then While n Mod div = 0 n = n / div S = S + div End While End If div = div + 1 End While

MsgBox("suma este" & S) End Sub End Class

You might also like