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.

Newcomers DBPro Corner / String and Variable Concatenation

Author
Message
Grayvyn Master
20
Years of Service
User Offline
Joined: 7th Dec 2003
Location: United States
Posted: 9th Dec 2003 01:39
I am trying to concat a string and a single/float into a string like...

num# = 0.1
s$ = "Hello world " + num#

The error is "types incompatible".
I can't find any function or operator like + or & that works.
I am using the trial version of DBP.
I come from a Visual Basic background.
Thanks for your help.

RPG World Online
http:www.rpgwo.com
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Dec 2003 01:42
wrap num in STR() function
you can't conctenate a string and a number
remember the end result will be a string

-RUST-
Easily Confused
21
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 9th Dec 2003 01:42 Edited at: 9th Dec 2003 01:45
You need str$()

s$ = "Hello World " + str$(num#)

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Easily Confused
21
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 9th Dec 2003 01:44
Dang! You beat me to it CattleRustler

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Dec 2003 01:44


-RUST-
Grayvyn Master
20
Years of Service
User Offline
Joined: 7th Dec 2003
Location: United States
Posted: 9th Dec 2003 01:45
heh, heh, I knew it would be simple
That's why I could not find it.
Thanks, it works now.

RPG World Online
<a href=http:\www.rpgwo.com>www.rpgwo.com</a>
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 9th Dec 2003 15:38
aargh visual basic. It worked in visual basic because it uses variant as its data type and basically doesnt care( i think).

"Any one for french fries n ketchup?"
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Dec 2003 16:15
yes variant is an evil evil thing, and it takes up 16 bytes in memory! Thank god vb.net did-away with ALL of vb6's stupidity

-RUST-
Grayvyn Master
20
Years of Service
User Offline
Joined: 7th Dec 2003
Location: United States
Posted: 9th Dec 2003 19:07
In VB6...
If you use str() then it returns a variant.
If you use str$() then it returns a string.
I do know that VB6 has many functions that are either
with $ or with out, like mid(), mid$() that work that way.
I have seen performance tests and the $ always works much faster.
any who...

RPG World Online
www.rpgwo.com
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Dec 2003 20:24
correct because a string is using 2 or 4 bytes, where a variant is using 16 always - because basically a variant needs to hold whatever the user tries to stuff in it like a catch-all. that is crap! Thank god vb.net did away with all of this. Now everything is an object, including every variable you define. The variable will inherit the underlying class so say you make

Dim strMyVar as string

Then you could immediately use

strMyVar.Trim, or .mid() or .Format(), or whatever base methods were inherited from the underlying string class...

.NET - It makes me goose-pimply!


-RUST-
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Dec 2003 20:27
nice I just added that to my sig...

-RUST-

VB.NET makes me all goose-pimply!
Easily Confused
21
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 9th Dec 2003 22:11
Quote: ".NET - It makes me goose-pimply!"

Are you sure you haven't picked up a rash

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.

Login to post a reply

Server time is: 2024-09-21 11:38:35
Your offset time is: 2024-09-21 11:38:35