| |

VerySource

 Forgot password?
 Register
Search
View: 872|Reply: 3

Super basic procedural problems

[Copy link]

8

Threads

19

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-1-6 11:00:01
| Show all posts |Read mode
I just learned VB, and I want the numbers in the two boxes to be equal to those in the third box. What is wrong, thank you. Wait online! !! !!
Private Sub Command1_Click ()
Dim s1%, s2%, s3%
Text3.Text = s3 = s2 + s1: Text1.Text = s1: Text2.Text = s2
End Sub
Reply

Use magic Report

8

Threads

19

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

 Author| Post time: 2020-1-6 11:21:01
| Show all posts
Come on! !! !!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-6 15:36:01
| Show all posts
1. It is recommended not to use ":"
2. The reward symbol is written in reverse, it should be
s1 = Text1.Text
s2 = Text2.Text
3. It seems you haven't understood the use of value-granting symbols
Text3.Text = s3 = s2 + s1
Is wrong, s3 is not needed at all
Correct writing
Text3.Text = s2 + s1
4.Text3.Text is a string type, and s1, s2 are integer types, so conversion is required.

amend as below
Private Sub Command1_Click ()
Dim s1%, s2%
s1 = cint (Text1.Text)
s2 = cint (Text2.Text)
Text3.Text = cstr (s2 + s1)
End Sub
Reply

Use magic Report

2

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-6 16:00:01
| Show all posts
You should use the Val function to convert text to numbers before adding them

Text3.text = val (text1.text) + val (text2.text)
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list