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

Encontrar Primos

This document contains Visual Basic code to find prime numbers less than a given value. It defines a function that takes an integer as input, clears any existing items from a list box, then uses a loop to check each number from 1 to the input value to see if it is only divisible by 1 and itself. Any numbers meeting this criteria of being prime are added to the list box. A button click event calls this function, passing the value from a text box control.

Uploaded by

Eddy
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 PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views1 page

Encontrar Primos

This document contains Visual Basic code to find prime numbers less than a given value. It defines a function that takes an integer as input, clears any existing items from a list box, then uses a loop to check each number from 1 to the input value to see if it is only divisible by 1 and itself. Any numbers meeting this criteria of being prime are added to the list box. A button click event calls this function, passing the value from a text box control.

Uploaded by

Eddy
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 PDF, TXT or read online on Scribd
You are on page 1/ 1

1 Encontrar los primos menores a X.

Diseo y salida del formulario

Bisual Basic Net 2008 2010


Public Class Form1 ''funcin para encontrar primos menores a x. Private Sub LlenarVector(ByVal x As Integer) Dim r, div As Integer LsBPrimos.Items.Clear() r = 1 While r <= x For i = 1 To r If r Mod i = 0 Then div = div + 1 End If Next If div <= 2 Then LsBPrimos.Items.Add(r) End If div = 0 r = r + 1 End While End Sub Private Sub BtnList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnList.Click Dim x As Integer x = Val(TxtX.Text) LlenarVector(x) End Sub End Class

You might also like