Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What did i do?
#1
ok i wrote this little bit of code so that the program would get the variable MAX_PLAYERS from an .ini file in the server folder but i keep getting this error
Compile error!
Expected: end of statement

and the code turns red.
heres the code
Code:
Public MAX_PLAYERS = GetVar(App.Path & "/Settings.ini", "[Maxes]", "MAX_PLAYERS")
Reply
#2
Add a const between public and maxplayers
Reply
#3
ok i added Const now it says "Constant expression required"
Code:
Public Const MAX_PLAYERS = GetVar(App.Path & "/Settings.ini", "[Maxes]", "MAX_PLAYERS")
Reply
#4
The variable needs to be set up at run time.
Try:
Code:
Public Players As Integer

Then, under your gameinit:
Code:
Players = GetVar(stuffsgoeshere)

It won't be a constnt, but it should work.
Reply
#5
ok thanks got it working finally, i think i havent compiled it yet so i dont know if it will work but VB isnt complaining Big Grin
Reply
#6
ok i just cant seem to get this right. i have another sub that im trying to get it to work on in the client side.
Code:
Private Sub Form_Load()
Dim Host As String
Dim Port As String
Dim filename As String
filename = App.Path & "Settings.ini"

Host = GetVar(filename, "[General]", Host)
Port = GetVar(filename, "[General]", Port)


frmMain.sockMain.RemoteHost = Host
frmMain.sockMain.RemotePort = Port
frmMain.sockMain.Connect
End Sub

i keeps saying runtime error 13 type mismatch and highlights this bit of code
Code:
frmMain.sockMain.RemotePort = Port

please tell me what i did wrong
Reply
#7
Probably a type mismatch? (Captain Obvious, away!) When it comes up with the error, point your mouse over both sides of the equation. You should be able to figure something out from that. I'd tell you, but I'm a newbie to VB6. ^^;
Reply
#8
well no duh its a type mismatch lol i just cant figure out what it was. ive looked over it like 5 times.
Reply
#9
ahh duh stupid me :oops: thanks
Reply
#10
Port = val(GetVar(filename, "[General]", Port))



Also, I don't think you need the [] around General. I could be wrong, but try it out.
Reply
#11
well i had the[] around general because that is the way i have it in my .ini file and it works but there need to be " " around Port. but thank you. now i can finally get this to work.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)