| View previous topic :: View next topic |
| Author |
Message |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed Oct 17, 2007 4:11 pm Post subject: conversion question |
|
|
I'm using REALbasic to make a program for my school, because it compiles cross-platform and my school uses macs(i know macs ) and I need to convert a string to an integer and an integer to a string. I know in delphi its
| Code: |
StrToInt(bla)
IntToStr(bla)
|
But this is vb, well almost vb, anyway what function do I use to to convert string to an integer and vice versa?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Wed Oct 17, 2007 5:34 pm Post subject: |
|
|
in C#.NET:
| Code: | Convert.ToString(1)
Convert.ToInt32("string") Or Convert.ToSingle("string") |
in C++.NET:
| Code: | Convert::ToString(1)
Convert::ToInt32("string") or Convert::ToSingle("string") |
Int32 = Integer
ToSingle = Float
ehhh
Edit:
its the First One ( Convert.ToString() Convert.ToSingle() )
same As C#
_________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed Oct 17, 2007 5:52 pm Post subject: |
|
|
Convert don't work in REALbasic =(
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Oct 17, 2007 6:06 pm Post subject: |
|
|
Not sure if REALbasic uses the same as VB6 but in VB6 its:
CInt(Other Val) // Convert To Integer
CStr(Other Val) // Convert To String
Edit:: Oh and theres nothing wrong with a Mac
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed Oct 17, 2007 6:20 pm Post subject: |
|
|
SO like...
| Code: |
bla = CInt(EditField1.Text)
EditField1.Text = CStr(bla)
|
?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Oct 17, 2007 6:21 pm Post subject: |
|
|
| Yea. What are you converting anyway? You might not even need to use them.
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed Oct 17, 2007 6:34 pm Post subject: |
|
|
oh, I'm making a GPA/Overall calc. I'm working on the overall. I am making it specifically for my comp teacher. There are 30 exercises so I should probably put 30 grade integers, but so far I have 8. Basically I need to store the percent he puts in each editbox(EditField) into each integer variable. So string to integer there. Then I have to switch the average percent, so like, 90-100 = A, 80-89 = B, etc. So integer to string there.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
DeltaFlyer Grandmaster Cheater
Reputation: 0
Joined: 22 Jul 2006 Posts: 666
|
Posted: Wed Oct 17, 2007 8:26 pm Post subject: |
|
|
Does your teacher not have a spreadsheet program?
I remember long ago when I was using VB6 I never knew of the concept of casting. Try putting the string directly into the integer variable, it may be automatically casted.
For converting percentages to marks though, that is not a integer to string casting, but rather a selection.
_________________
Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for? |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Oct 17, 2007 8:32 pm Post subject: |
|
|
| As long as the string is a numeric value only, it can be casted to other datatypes automatically. But if it contains other things; symbols, letters, etc., you need to alter the string before attempting to cast it.
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed Oct 17, 2007 8:55 pm Post subject: |
|
|
Well, he keeps our grades in excel worksheet. But he has to do all the calculations and crap manually. And theres lots of stuf in there.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
DeltaFlyer Grandmaster Cheater
Reputation: 0
Joined: 22 Jul 2006 Posts: 666
|
Posted: Wed Oct 17, 2007 9:04 pm Post subject: |
|
|
Excel could do the same calculations your program will need to do with much less programming involved and greater portability.
_________________
Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for? |
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Oct 18, 2007 3:53 am Post subject: |
|
|
if this is true, your teacher should go work in the lunch line
as he is retarded
_________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu Oct 18, 2007 3:15 pm Post subject: |
|
|
Well, I actually don't know how he does the grades. I am not familiar with excel and we have to use it to keep a log on where we are in exercises but I did not that something like excel did those kind of calculations.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Thu Oct 18, 2007 4:37 pm Post subject: |
|
|
| Excel is great for things like that. It's very easy to quickly calculate a bunch of things like that (grades for instance). Once you type the formula, all you have to do is drag it by it's little selection handle to wherever else you want or need the same formula and it will automatically update itself for every space it's in.
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Thu Oct 18, 2007 5:03 pm Post subject: |
|
|
| DeltaFlyer wrote: | | Excel could do the same calculations your program will need to do with much less programming involved and greater portability. |
lol
|
|
| Back to top |
|
 |
|