Home > Software engineering >  VB code
VB code

Time:09-23

The code below
 Private Sub Command1_Click () 
Dim sum As Single, As a Single
A=Text1
If a & gt; Then=2000
Sum=a + a * 0.1
The Else
Sum=a + 1
Text2. Text=sum
End the If
End Sub

This code, click the command button, text box input a value greater than 1, 2000, a text box 2 cannot output?

CodePudding user response:

You only to the Else branch in output!
The statement Text2. Text=End If the sum moved to behind,

CodePudding user response:

Can have no what, also do not see the Text2. Where is the Text=sum,

Change the following:
 Private Sub Command1_Click () 
Dim sum As Single, As a Single
A=CSNG (Text1. Text)
If a & gt; Then=2000
Sum=a + a * 0.1
The Else
Sum=a + 1
End the If
Text2. Text=sum
End Sub

CodePudding user response:

If no matter how much is the input, all want to be in Text2 output data,
Is that your code has logic errors, the Text2. End if Text=sum moved to behind,

CodePudding user response:

Thank you, I see, I put the code under the simplified
 Private Sub Command1_Click () 
Dim As a Single
A=Text1
If a & gt; Then=2000
A=a + a * 0.1
The Else
A=a + 1
End the If
Text2=a
End Sub

There is a problem a=Text1 with a=Text1. The meaning of the text is the same?

CodePudding user response:

The Text frame's "default property" is the Text property,
Therefore:
A=Text1
A=Text1. Text
The two words of code are the same meaning,

However, I feel or to write a complete "object. The property is better," a look will understand which attributes, operations
Don't need to "think about what should be the operation properties",

CodePudding user response:

The default kill people!

CodePudding user response:

Well, thank you! Sometimes encountered a=Val (text1. Text), why not use a=text1. The text?

CodePudding user response:

refer to 7th floor LZW201141 response:
well, thank you! Sometimes encountered a=Val (text1. Text), why not use a=text1. The text?

Refer to the 6th floor

CodePudding user response:

refer to the eighth floor zhao4zhong1 response:
Quote: refer to 7th floor LZW201141 response:

Well, thank you! Sometimes encountered a=Val (text1. Text), why not use a=text1. The text?

Refer to the sixth floor


Your 6th floor, with 7 floor of the building Lord problem has a hair!

CodePudding user response:

references 9 f Chen8013 response:
Quote: refer to the eighth floor zhao4zhong1 response:

Quote: refer to 7th floor LZW201141 response:

Well, thank you! Sometimes encountered a=Val (text1. Text), why not use a=text1. The text?

Refer to the sixth floor


Your 6th floor, with 7 floor of the building Lord problem has a hair!

Refuse to use the default in order to avoid the default of side effects,

CodePudding user response:

Val (text1). The content of the text is converted into a numeric, such as: you input "456", is your definition of single type single precision, avoid mistaken for string type mismatch caused by mistake, I understand it, if there are any wrong, please correct me,

CodePudding user response:

Of course can't output, because you write output statements in the else branch, when you enter 2000, established conditions, carried out directly after the if statement, if the branch establishment on the end of if statements,

CodePudding user response:

See me all of the code of the

First is the logical problem. As long as the building Lord sentence by sentence according to your own thoughts a finger code simulation over the brain never make it.

Second is the default attributes and abuse of the default type conversion. If this problem is not correct, write a little bit big application in the future will take the consequences. Suggest the building form in every assignment before first think on both sides of the equal sign each of the variables and the content of what type.

Code style, the indentation of what has been is not a problem.

CodePudding user response:

People will be what, then you can have,
  • Related