Microsoft Excel VBA Programming for the Absolute Beginner Second Edition phần 4

Tham khảo tài liệu 'microsoft excel vba programming for the absolute beginner second edition phần 4', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 4 Loops and Arrays The GetOperatorType procedure tests the Value property of the Option Button controls to see which operator has been selected by the user. If the user selects the option Any then the GetRandomOperator procedure is called to generate a random number between 1 and 4. This procedure writes the operator to the merged cells I defined with the name Operator and is only used when the operator is randomly chosen by the program. You should recall that when a user selects a specific operator the Click event procedure of the Option Button control writes that operator to the Operator range. Private Sub GetOperatorType Gets the operator selected by the user. If True Then opType 1 If True Then opType 2 If True Then opType 3 If True Then opType 4 If True Then GetRandomOperator End Sub Private Sub GetRandomOperator Randomly selects the type of operator for the question. Randomize opType Int 4 Rnd 1 Select Case opType Case Is 1 Range Operator .Value Case Is 2 Range Operator .Value - Case Is 3 Range Operator .Value x Case Is 4 Range Operator .Value Case Else Range Operator .Value End Select End Sub A question s operands are written to the appropriate cell locations F8 G9 defined name LeftOperand and I8 I9 defined name RightOperand with the GetOperands sub procedure that calls the GetRandomNumber function procedure in order to generate and return the operands randomly. If the mathematical operation is division the GetRandomNumber function uses a loop that will continue to iterate until a second operand is found that results in a non-fractional answer. The VBA operator Mod is used to test the two random numbers for a remainder of zero. Microsoft Excel VBA Programming for the Absolute Beginner Second Edition The GetOperands sub procedure is called from the Click event of the Command Button control cmdBegin and the Change event of the worksheet listed later . Private Sub GetOperands .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
24    21    1    01-12-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.