This document contains Visual Basic code that defines a form with three buttons. The first button, when clicked, takes a user-inputted number and stores random integers in a vector of that length. It then sorts the vector in ascending order and displays the sorted values. The second button clears the text boxes. The third button closes the form.
1 of 2
Download to read offline
More Related Content
Trabajo de case
1. TRABAJO DE CASE
POR: ANGEL YASACA, JONATHAN LLANGO , GUAMAN EDISON.
SEXTO “E”
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim n, i, j, vectemp As Integer
n = Val(TextBox1.Text)
Dim vector(n) As Integer
For i = 1 To n
vector(i) = InputBox("vector " & i)
Next i
For i = 1 To n
For j = 1 To n = 1
If vector(i) > vector(j) Then
vectemp = vector(j)
vector(j) = vector(i)
vector(i) = vectemp
End If
Next
Next
For i = 1 To n
TextBox2.Text = TextBox2.Text & vector(i) & vbCrLf
Next i
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
TextBox1.Text = " "
TextBox2.Text = " "
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
End
End Sub
End Class