Home > Software engineering >  What's the problem with this program, please
What's the problem with this program, please

Time:11-02

 Private Sub Text2_Change () 
Dim a, b, c As Single
A=CSng (Text1. Text)
B=CSng (Text2. Text)
C=CSng (Text3. Text)
If Option1. Value=https://bbs.csdn.net/topics/True Then
Call opt1
Text5. Text=a/b
ElseIf Option2. Then Value=https://bbs.csdn.net/topics/True
Call opt2
Text5. Text=c/b
End the If
End Sub


General window function declaration
 Sub opt1 () 
Form1. Text3. Locked=True
Form1. Text3. BackColor=& amp; H80000010
End Sub
Sub opt2 ()
Form1. Text1. Locked=True
Form1. Text1. BackColor=& amp; H80000010
End Sub

What's the problem with this program, please, thank you

CodePudding user response:

The problem is in the Text5. Text assignment
The result of calculation is numerical
And it is good to Str
Text5. Text=Str (a/b)

CodePudding user response:

reference 1st floor SongPixy response:
Text5. The problem is the Text on the assignment
The result of calculation is numerical
And it is good to Str
Text5. Text=Str (a/b)


When in Text2. Text input value types do not match, how to return a responsibility, I think no problem

CodePudding user response:

Can see

Dim a, b, c As String
A=Text1. Text
B=Text2. Text
C=Text3. Text
Then
Text5. Text=Str (CSng/CSng (a) (b))

CodePudding user response:

O l right.
Problem statement in text2_change text2 input times wrong, of course,

CodePudding user response:

reference 4 floor flyinthesky response:
o l right.
Problem statement in text2_change text2 input times wrong, of course,


Excuse me, then how to change

CodePudding user response:

In two text2_change text5. Tex=change to the following:
Text5. Text=CSTR (a/b)
Text5. Text=CSTR (c/d)

CodePudding user response:

There is nothing wrong with the code.
A=CSng (Text1. Text)
B=CSng (Text2. Text)
C=CSng (Text3. Text)

'when you change the content of the Text2, be sure that Text1 Text2 Text3 content are numerical.
For the following changes:
.
.
If IsNumeric (Text1. Text) And IsNumeric (Text2. Text) And IsNumeric (Text3. Text) Then 'judgment Text1 Text2 Text3 for numerical
A=CSng (Text1. Text)
B=CSng (Text2. Text) 'increase a if b=0 then b=1' b can not equal to zero, or behind will be wrong.
C=CSng (Text3. Text)
The Else
A=0
B=1 'b can not equal to zero, or behind will appear error.
C=0
'Text1 Text2 Text3 with non-numerical content
End the If
.
.

CodePudding user response:

B can not equal to zero, all three text box must be to limit is an integer

CodePudding user response:

Wait for master ` `

CodePudding user response:

Problems on text2_change this event, as long as the content of text2 changes, immediately start the following program, the key is you want to achieve this goal the thinking of is what? Why the program should be placed under the text2_change text2 change events? As soon as text2 input one character at a time, in that its content is changed, at this point, the following program has triggered, so please think workarounds, don't use text2_change this event,

CodePudding user response:

Don't have to convert to text assignment, or you literally in the program to try to know,
  • Related