Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Create a VBA subroutine namedAccountinformation1 that: declares each of the f

ID: 3872140 • Letter: 1

Question

1. Create a VBA subroutine namedAccountinformation1 that: declares each of the following types of variables: Integer, String, Long, Array, Double, Worksheet, Range, Cell, and a variable that can store any data-type. declares a variable for a user-defined (complex) data-type that can contain the following a. b. customer's bank account number, account-name, number of withdrawals allowed, and balance. i. c. assigns a value to each of the variables declared in (a) d. displays the name of each variable in (a) and the value assigned. 2. Create a VBA subroutine Accountinformation2 Perform steps (1a.) and (1b.) in subroutine Accountinformation2, similar to what you did in Accountinformation1. Enhance subroutine Accountinformation2 to do the following a. b. i. Prompt the users for the current-interest-rate. [Check the textbook and the class examples for the syntax on how to prompt/request user-input] ii. Compute the interest-earned on the account as: balance current-interest-rate. Display the account-number, account-name, balance, current-interest-rate, and the interest-earned. Each piece of information you display must be on separate line (Use only ONE MsgBox command if possible. Remember the vbTab, and vbNewLine built-ins) After step (c), display a question: "Do you want to see more transactions?" [Your display should give the user options to click Yes', 'No', or 'Cancel' in response to the question c. d.

Explanation / Answer


Sub AccountInformation1()

'1a
'Declare variables

Dim integer_type As Integer
Dim flag As String
Dim ip As Long
Dim a(0 To 5) As Integer
Dim ip1 As Double
Dim wb As Workbook: Set wb = ThisWorkbook
Dim ws As Worksheet

'Dim ws As Worksheet
Dim eg As Range
Dim range_test As Range
Dim b As Variant

'Ask for user_input

Dim user_input As Variant

user_input = InputBox("Enter either account number,account-name,number of withdrawls allowed or balance")

'Initialize variables

integer_type = 1
flag = "abc"
ip = 1147483647
a(0) = 1
a(1) = 2
ip1 = 3.3333333
Set ws = wb.Sheets("Sheet1")
Set eg = ws.Range("A1:A5")
Set range_test = ws.Range("A1")
b = Array(1, "a")

' Display varaiables

MsgBox "Integer " & integer_type
MsgBox "Flag " & flag
MsgBox "Long " & ip
MsgBox "Array " & a(0) & " ," & a(1)
MsgBox "Double " & ip1
MsgBox "Worksheet " & ws.Name
MsgBox "Range " & eg.Value
MsgBox "Cell" & range_test.Value
MsgBox "Variant" & b

End Sub