user2792832
user2792832

Reputation: 41

End of statement expected - defining a variable

I get the error "End of statement expected" when I try and declare the variable VRAM

Dim VRAM As String

If VRAMT.Value = 1 Then
    VRAM = 256m
    VRAMT.Value = 2 Then
    VRAM = 512m
    VRAMT.Value = 3 Then
    VRAM = 768m
    VRAMT.Value = 4 Then
    VRAM = 1024m
    VRAMT.Value = 5 Then
    VRAM = 1280m
    VRAMT.Value = 6 Then
    VRAM = 1636m
    VRAMT.Value = 7 Then
    VRAM = 1792m
    VRAMT.Value = 8 Then
    VRAM = 2048m
End If

Thanks for any help. It is probably really easy, but I can't seem to work it out :(

Upvotes: 1

Views: 303

Answers (1)

dcp
dcp

Reputation: 55424

You need to use an ELSEIF on each subsequent line after the first IF, or use SELECT CASE instead.

  If VRAMT.Value = 1 Then
        VRAM = 256m
  ELSEIF VRAMT.Value = 2 Then
        VRAM = 512m
  ...
  End If

Here's how to do it with SELECT CASE

Select Case VRAMT.Value
    Case 1
        VRAM = 256m
    Case 2
        VRAM = 512m
    ...
End Select

Upvotes: 3

Related Questions