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

Tham khảo tài liệu 'microsoft excel vba programming for the absolute beginner second edition phần 3', 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 3 Procedures and Conditions Function calls to determine the number of die displaying each value. numOnes GetNumOnes numTwos GetNumTwos numThrees GetNumThrees numFours GetNumFours numFives GetNumFives numSixes GetNumSixes Call functions for the result of the hand. result IsNothingOrStraight numOnes numTwos numThrees numFours numFives numSixes result result IsOnePair numOnes numTwos numThrees _ numFours numFives numSixes result result IsTwoPair numOnes numTwos numThrees _ numFours numFives numSixes result result IsThreeOfAKind numOnes numTwos numThrees _ numFours numFives numSixes result result IsFourOfAKind numOnes numTwos numThrees _ numFours numFives numSixes result result IsFiveOfAKind numOnes numTwos numThrees _ numFours numFives numSixes result result IsFullHouse numOnes numTwos numThrees _ numFours numFives numSixes result Range C12 .Value result End Sub The line continuation _ character tells VBA that I really want just one line of code but I need to type it on more than one line in the text editor. Make sure there is a single space between the last character and the underscore before proceeding to the next line. The function procedures GetNumOnes GetNumTwos GetNumThrees GetNumFours GetNumFives and GetNumSixes are called from the DisplayResult sub procedure and they determine the number of dice with a particular value. These functions use numerous If Then code Microsoft Excel VBA Programming for the Absolute Beginner Second Edition structures to check the values of the dice stored in the second row of the spreadsheet cells B2 through F2 . The random number function Rnd generated these values earlier in the program. A variable is then incremented if its associated value is found in a spreadsheet cell. These functions effectively determine how many dice show the value 1 2 3 4 5 or 6. Private Function GetNumOnes As Integer Determine the number of dice displayed with a value of 1 Dim numOnes As Integer If Range B2 .Value 1 Then numOnes numOnes 1 If Range

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
Đã 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.