And the program of summing up from the other side doesn't work.

Asked 2 years ago, Updated 2 years ago, 106 views

I would like to create a program that asks for the sum of X to Y.You also have to create a program that you want from the other side.Exit Sub is not available.It does not respond when looking for a large to a small number.What should I do?
I'd like to enter a number in the two text boxes and display the sum in the third text box.

Access VBA

Private SubtnWa_Click()
   
DimlX As Long
Dimly As Long
Dimls As Long
Dimi As Long
DimSouwa As Long

lX=txtX.Value
lY = txtY.Value

If X > lY Then
     lS = -1
Else —lS = 1

lSouwa = 0

Fori=lX Tooly SteplS
     lSouwa=lSouwa+i
Next i

txtSouwa.Value=lSouwa

End If
End Sub

vba ms-access

2022-09-30 11:04

1 Answers

If Condition Then
    treatment when conditions are true
Else
    Handling When the Conditions Are False Conditions
End If

The IF statement is conditionally branched as above, so
For lX>lY, only lS=-1 runs
Otherwise, Else to End If processing is performed.

If it is a conditional branch to set the value of lS,
Else: I think you can move End If to the next line of lS=1.


2022-09-30 11:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.