acaccamise
New Member
- Joined
- Apr 25, 2016
- Messages
- 4
I am doing a code and i keep getting "run-time error 13" on the line
MaxChars = InputBox("Maximum number of characters:")
Someone please help!
The code:
Public Sub AestheticAgeCalc()
Dim MaxChars As Integer
Dim CharCount As Integer
Dim CharName As String
Dim ActualAge As Double
Dim AestheticAge As Double
Dim TwentyFirstYear As Double
Dim DeathYear As Integer
Dim OldYear As Integer
Dim CurrentYear As Integer
Dim OldAestheticAge As Double
Dim GrowthRate As Double
MaxChars = InputBox("Maximum number of characters:")
CharCount = 1
Do While CharCount <= MaxChars
CharName = InputBox("Character name:")
If CharName = "" Then
Exit Sub
End If
ActualAge = InputBox("How old is " & CharName & "?")
If ActualAge <= 21 Then
AestheticAge = ActualAge
MsgBox "" & CharName & " looks " & AestheticAge & " year(s) old."
CharCount = CharCount + 1
ElseIf ActualAge > 21 Then
CurrentYear = InputBox("Year during which " & CharName & " is " & ActualAge & ":")
TwentyFirstYear = InputBox("" & CharName & "'s 21st birth year:")
If TwentyFirstYear > CurrentYear Then
MsgBox "This contradicts previously inputted data!"
Exit Sub
End If
DeathYear = InputBox("" & CharName & "'s death year:")
OldYear = InputBox("Enter an old year (no earlier than " & CharName & "'s 21st birth year) for which you know " & CharName & "'s corresponding age:")
If OldYear < TwentyFirstYear Then
MsgBox "This year is too early!"
Exit Sub
ElseIf OldYear > CurrentYear Then
MsgBox "This year is too late!"
Exit Sub
End If
OldAestheticAge = InputBox("How old does " & CharName & " look in " & OldYear & "?")
GrowthRate = InputBox("How many years does it take " & CharName & " to appear to age one year?")
AestheticAge = ((CurrentYear - OldYear) / GrowthRate) + OldAestheticAge
MsgBox "" & CharName & " looks " & AestheticAge & " years old."
CharCount = CharCount + 1
End If
Loop
End Sub
MaxChars = InputBox("Maximum number of characters:")
Someone please help!
The code:
Public Sub AestheticAgeCalc()
Dim MaxChars As Integer
Dim CharCount As Integer
Dim CharName As String
Dim ActualAge As Double
Dim AestheticAge As Double
Dim TwentyFirstYear As Double
Dim DeathYear As Integer
Dim OldYear As Integer
Dim CurrentYear As Integer
Dim OldAestheticAge As Double
Dim GrowthRate As Double
MaxChars = InputBox("Maximum number of characters:")
CharCount = 1
Do While CharCount <= MaxChars
CharName = InputBox("Character name:")
If CharName = "" Then
Exit Sub
End If
ActualAge = InputBox("How old is " & CharName & "?")
If ActualAge <= 21 Then
AestheticAge = ActualAge
MsgBox "" & CharName & " looks " & AestheticAge & " year(s) old."
CharCount = CharCount + 1
ElseIf ActualAge > 21 Then
CurrentYear = InputBox("Year during which " & CharName & " is " & ActualAge & ":")
TwentyFirstYear = InputBox("" & CharName & "'s 21st birth year:")
If TwentyFirstYear > CurrentYear Then
MsgBox "This contradicts previously inputted data!"
Exit Sub
End If
DeathYear = InputBox("" & CharName & "'s death year:")
OldYear = InputBox("Enter an old year (no earlier than " & CharName & "'s 21st birth year) for which you know " & CharName & "'s corresponding age:")
If OldYear < TwentyFirstYear Then
MsgBox "This year is too early!"
Exit Sub
ElseIf OldYear > CurrentYear Then
MsgBox "This year is too late!"
Exit Sub
End If
OldAestheticAge = InputBox("How old does " & CharName & " look in " & OldYear & "?")
GrowthRate = InputBox("How many years does it take " & CharName & " to appear to age one year?")
AestheticAge = ((CurrentYear - OldYear) / GrowthRate) + OldAestheticAge
MsgBox "" & CharName & " looks " & AestheticAge & " years old."
CharCount = CharCount + 1
End If
Loop
End Sub