Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How change string values in a variable ?

Author
Message
Waldemar Lima
9
Years of Service
User Offline
Joined: 27th Nov 2014
Location: Brasil
Posted: 8th Jun 2015 03:11
how do I change the value of a string variable?
example.

I declared a variable called "status"

Dim Status As String = "Client"

note = Client is the default value of the variable.

when I run an "If" I want the value of the variable is "server"
  example.

   If condition = 1
       mudavalordastringpara "Server"
   endif

how I do it? already tried to "replace" does not work ...

PrintC("Hello EveryOne !&quot
Nieb
10
Years of Service
User Offline
Joined: 13th May 2014
Location: Lurking
Posted: 8th Jun 2015 03:19 Edited at: 8th Jun 2015 03:22
The $ character after a variable name is used to define it as a string.

http://www.appgamekit.com/documentation/principles/1_datatypes.htm



AGK: 2.0.14b Development System: Windows 7 Pro 64-bit
Android Device: Samsung Galaxy Tab 2 7inch (gt-p3113) Android OS: KitKat 4.4.4 (Slimkat Rom)
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Jun 2015 10:42 Edited at: 8th Jun 2015 10:43
Firstly, you need to declare the variable correctly...



Then you need to simply use "="



I have no idea where mudavalordastringpara comes into it!

Quote: "The $ character after a variable name is used to define it as a string."


The $ is not required if you explicitly declare the variable as above

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Waldemar Lima
9
Years of Service
User Offline
Joined: 27th Nov 2014
Location: Brasil
Posted: 9th Jun 2015 03:52
when i execute "if" , show this error in compiler

http://prntscr.com/7es08b

PrintC("Hello EveryOne !&quot
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 9th Jun 2015 09:15
That's because you have put ClientID inside the str() command.
That forces the compiler to convert the integer value of ClientID into a string which is not what you want.

There are two ways to correct what you are trying to do.

Method 1: I wouldn't recommend doing it this way but it proves that ClientID is now a string:


Method 2: This is the better way to go:


AGK V2 user - Tier 1 (mostly)

Login to post a reply

Server time is: 2024-09-29 01:16:23
Your offset time is: 2024-09-29 01:16:23