Use VB to edit a calculator, you need to use an array, look at the code below, welcome to find the distraction!

xiaoxiao2021-03-06  70

This is my code, please help me see what problem: (I want to use an array to make a calculator) Option Explicitdim shu1 as double, SHU2 AS DOUBLE 'The two digital DIM RESULT AS DOUBLE' has made an operation Results DIM Process, Process0, Process1, Process2, Process3, Process4 As Variant 'Save Number 1 Process DIM JUDGE AS VARIANT' DIM JUDGE AS VARIANT 'Judging the operator

Private submmand1_click (index as integer) '0-9 Number key text1.text = text1.text & indextext1.setfocusend Sub

Private submmand1_keypress (index as integer) 'blocks the keyboard input, but I don't know why Keyascii = 0nd Sub

Private submist2_click (index as integer) '"" "" key text1.text = text1.text & "." End Sub

Private submmand3_click () 'Return button if text1.text = "" Thenexit suvestext1.text = left (text1.text, len (text1.text) - 1) End Sub

Private sub command4_click () 'Clear Table Text1.Text = "" End Sub

Private submed5_click (index as integer) 'Making an operation, always feel that there is a problem with the logic Shu1 = Val (Text1.Text) process = shu1text1.text = "" if judge = command5 (0) ThenProcess0 = shu1 command (0) ElseIf judge = Command5 (1) Thenprocess1 = shu1 Command5 (1) ElseIf judge = Command5 (2) Thenprocess2 = shu1 Command (2) ElseIf judge = Command5 (3) Then process3 = shu1 Command5 (3) End Ifshu2 = Val (Text1.Text) End Sub

Private Sub Command6_Click () 'equals result = process shu2Text1.Text = resultIf process0 Thenresult = shu1 shu2ElseIf process1 Thenresult = shu1 - shu2ElseIf process2 Thenresult = shu1 * shu2ElseIf process3 Thenresult = shu1 / shu2End IfEnd Sub

Private sub text1_change () if judge = false thenshu2 = val (text1.text) end iftext1.setfocusend SUB

转载请注明原文地址:https://www.9cbs.com/read-110369.html

New Post(0)