Home > Software engineering >  Help ah (a dual programming form)
Help ah (a dual programming form)

Time:10-04

Design a program interface, there are two forms of application, the user in the Form Form (input Form) "please enter the order number number text box" enter a valid number, press the return key, in the Form of "Picture1" picture box in front of the output sequence number, click the "order" button, start Form2 Form, called bubble Sort subprocesses Sort and the sorting result in Form2 (output) Form "Picture1" picture box output, in Form2 (output) Form of "please enter a number to find" in the text box input to find the number, click the "Search" button, find the function called process (Search), Search results in the "Search results", according to the text box click on the "end" button to end the application to run,

Pray god grant instruction!
The first code is a function declaration
 Public Sub sort ((a) As an Integer) 
Dim n As Integer
Dim t As Integer
(n=UBound (a))
For I=1 To n - 1
For j=I + 1 To n
If a (I) & gt; A (j) Then
T=a (I)
A (I)=a (j)
A (j)=t
End the If
Next j
Next I
End Sub

The second is the picture1 form1 output, I want to change the output to each line 15,
how to change?
 Private Sub Text1_KeyPress (KeyAscii As Integer) 
Dim (a)
Dim As Integer I
Dim n As Integer
Dim s As String
Dim the count As Integer
N=Val (Text1. Text)
If n & gt; 0 Then
ReDim a (n - 1)
For I=0 To n - 1
Randomize
A (I)=Int (Rnd * 101)
S=s & amp; A (I) & amp; "
"Next I
If KeyAscii=13 Then
Picture1. Print s
End the If
End the If
End Sub


There is, how to call the second window, realize the command1 sorted after digital picture1 in form2
output?I am a little white, just contact with vb still hope everybody can teach
Best can have a full set of code

CodePudding user response:

Refer to the following code: (you have to find what is the purpose of?)
 Private Sub Command1_Click () 
"A form + + 2 a button a picturebox + a + a listbox textbox
"' random data and output the sorted results
Dim As Integer k
K=CInt (Val (Text1. Text))
If k & gt; 0 And k & lt; 31 Then
Dim I As an Integer, w1 As String, w2 As String, n As Integer
"' List1. Sorted=True 'in the design of interface (used to sort)
List1. Clear
For I=1 To k
N=Int (Rnd * 101)
W1=w1 & amp; W2 & amp; CStr (n)
List1. AddItem Format $(n, "000")
W2=""
If I Mod 15=0 Then w1=w1 & amp; VbCrLf: w2=""
Next
Pic1. Print w1 'output in Pic1 before ordering the string
"' output sorted data in pic2
W1="" : w2=" "
For I=0 To List1. ListCount - 1
W1=w1 & amp; W2 & amp; CStr (CInt (List1. List (I)))
W2=""
If (I + 1) Mod 15=0 Then w1=w1 & amp; VbCrLf: w2=""
Next
Pic2. Print w1 'output in Pic2 before ordering the string
"' if you use two forms, refer to the following
"' Form2. Show
"' Form2. Pic1. Print w1
The Else
MsgBox "in the text box, please enter a number 1 ~ 30"
End the If
End Sub
  • Related