Hi everyone! I'm currently taking a programming course, and we're using Visual Basic to create a simple calculator that sums two numbers. Unfortunately, I've run into a compile error while coding on the school's older computers, which has been quite frustrating. I suspect it might be an issue with the machines, but I'd greatly appreciate any insight or help to fix this error. Here's the code I've written:
```vb
Private Sub Command1_Click()
Dim Num1 As Double, Num2 As Double
Sum as Double
Num1 = Val(Text1.Text)
Num2 = Val(Text2.Text)
Sum = Num1 + Num2
Label3.Caption = "The sum is" & Sum
End Sub
```
I'm really puzzled because my classmates have nearly identical codes that work perfectly. Any advice on what might be wrong? Thanks a lot, and apologies for any grammatical errors—I'm not a native English speaker!
2 Answers
First off, can you share the exact error message you’re seeing? That would help a lot! From a quick look at your code, I noticed that there might be some formatting issues. Be sure there’s a comma separating your variable declarations. It should be `Dim Num1 As Double, Num2 As Double, Sum As Double`. Without seeing the full error text, it’s hard to pinpoint the issue, but you really need to double-check your error message for clues.
It looks like you're missing a declaration for the Sum variable. You need to declare it with `Dim` like this: `Dim Sum As Double`. So your line should read `Dim Num1 As Double, Num2 As Double, Sum As Double`. It’s a common mistake, so don’t worry about it! Also, I get why you're frustrated; sometimes these compilers can be finicky, especially on older computers. Good luck!

Thanks for your reply! The error message says: "Compile error: Method or data member missing." I think I’ll take another look at my syntax too.