Stuck on a section of code

Hey all,

I’m trying to display a picture based on a previously set variable only if a certain variable is above 0. It displays the “guards” for a location in my game.

I get syntax errors for the ElseIf sections, but I tried End If on each of those sections and got the same result, syntax error.

Also the line: fname = Str(gangpict(gunum(1)) + “sm.jpg” is giving me a Type Mismatch error: Expected Int32 but got String, even though I defined fname as a string already.

gangpict(x) is set to the number of the picture to load (1-70), and gunum() is set to the number out of the 10 characters that are guarding it (1-10). If gunum(x) is 0, it obviously doesn’t need to display anything.

Can someone help me with this code? I’m lost as to what i’m doing wrong.

Code:

if gunum(1)>0 Then fname = Str(gangpict(gunum(1)) + "sm.jpg" #if DebugBuild f = getFolderItem("").Parent.Child(fname) #else f = getFolderItem(fname) #endif ImageWell2.Visible=True ImageWell2.Image = Picture.Open(f) Label28.Visible=True Label28.Text=Str(gua(1)) +"/" + Str(gud(1)) ElseIf gunum(2)>0 Then fname = Str(gangpict(gunum(1)) + "sm.jpg" #if DebugBuild f = getFolderItem("").Parent.Child(fname) #else f = getFolderItem(fname) #endif ImageWell3.Visible=True ImageWell3.Image = Picture.Open(f) Label29.Visible=True Label29.Text=Str(gua(2)) +"/" + Str(gud(2)) ElseIf gunum(3)>0 Then fname = Str(gangpict(gunum(1)) + "sm.jpg" #if DebugBuild f = getFolderItem("").Parent.Child(fname) #else f = getFolderItem(fname) #endif ImageWell4.Visible=True ImageWell4.Image = Picture.Open(f) Label30.Visible=True Label30.Text=Str(gua(2)) +"/" + Str(gud(2)) End If

#ELSEIF

About the syntax errors… you are missing a closing bracket:

fname = Str(gangpict(gunum(1))) + "sm.jpg"

Your code example has 3 opening brackets but only 2 closing brackets.

I spot two places where brackets are missing.

Yep the brackets were the issue with that, thanks all!