| Mirage Source http://www.miragesource.net/forums/ |
|
| What did i do? http://www.miragesource.net/forums/viewtopic.php?f=201&t=3659 |
Page 1 of 1 |
| Author: | Pbcrazy [ Mon Apr 28, 2008 10:35 pm ] |
| Post subject: | What did i do? |
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")
|
|
| Author: | Lea [ Tue Apr 29, 2008 12:48 am ] |
| Post subject: | Re: What did i do? |
I haven't use VB in a while, but I believe you need a variable type Public Int MaxPlayers, for example.. |
|
| Author: | Stomach Pulser [ Tue Apr 29, 2008 1:02 am ] |
| Post subject: | Re: What did i do? |
Add a const between public and maxplayers |
|
| Author: | Pbcrazy [ Tue Apr 29, 2008 1:05 am ] |
| Post subject: | Re: What did i do? |
ok i added Const now it says "Constant expression required" Code: Public Const MAX_PLAYERS = GetVar(App.Path & "/Settings.ini", "[Maxes]", "MAX_PLAYERS")
|
|
| Author: | Stomach Pulser [ Tue Apr 29, 2008 1:38 am ] |
| Post subject: | Re: What did i do? |
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. |
|
| Author: | Pbcrazy [ Tue Apr 29, 2008 2:02 am ] |
| Post subject: | Re: What did i do? |
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 |
|
| Author: | Pbcrazy [ Sun May 04, 2008 1:02 am ] |
| Post subject: | Re: What did i do? |
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 |
|
| Author: | Soyokaze [ Sun May 04, 2008 1:33 am ] |
| Post subject: | Re: What did i do? |
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. ^^; |
|
| Author: | Pbcrazy [ Sun May 04, 2008 1:58 am ] |
| Post subject: | Re: What did i do? |
well no duh its a type mismatch lol i just cant figure out what it was. ive looked over it like 5 times. |
|
| Author: | Asrrin29 [ Sun May 04, 2008 2:17 am ] |
| Post subject: | Re: What did i do? |
you are Dim'ing Host and Port as strings when they should be Long's. GetVar Function returns numerical values, and you are trying to put a numerical value into a string, and then trying to put a string into RemoteHost and RemotePort. |
|
| Author: | Pbcrazy [ Sun May 04, 2008 2:25 am ] |
| Post subject: | Re: What did i do? |
ahh duh stupid me |
|
| Author: | shaded [ Sun May 04, 2008 3:25 am ] |
| Post subject: | Re: What did i do? |
Port = val(GetVar(filename, "[General]", Port)) Also, I don't think you need the [] around General. I could be wrong, but try it out. |
|
| Author: | Pbcrazy [ Sun May 04, 2008 4:29 am ] |
| Post subject: | Re: What did i do? |
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. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|