Search the archive:
YaBB - Yet another Bulletin Board
 
   
 
Page Index Toggle Pages: 1
Send Topic Print
Visual Studio .net 2003 (Read 144 times)
Mar 2nd, 2005 at 10:25pm

Jared   Offline
Colonel
I'd rather be flying...
Uniontown, Ohio

Gender: male
Posts: 12621
*****
 
OK so I'm trying to write a program in visual studio dot net 2003.

this program isn't too difficult and the isntructor says we should try and use the substring method to pull out specific sequences of characters.

for our program we are taking arabic numbers and turning them into roman numerals....

so for this program we want to evaluate the first character, and then assign a new variable whatever roman letter means the same...

according to the help info, and the prof you have a variable Variable1 in this example....we are supposed to be able to say the following...

variable1.substring(0,1)

the zero and one denote the start position and the number of characters to pull out of the sequence of letters/numbers....

well my problem is whenever I try to use the substring method it comes up and gives me an error telling me that the substring method does not exist within the program.  According to the professor the substring method does not have to be called upon before use.

The only thing I'm not sure is the format the data should be in in order to use the substring method?

I've tried string (text) and double) formats with no luck...

Can anybody tell me what I'm doing wrong? I would greatly appreciate any info..Wink
 
IP Logged
 
Reply #1 - Mar 4th, 2005 at 8:55am

krylite   Offline
Colonel
ftg VA LH584

Posts: 89
*****
 
Do you have the header lines?:

#using <mscorlib.dll>
using namespace System;


I'm guessing your string object's class doesn't have that substring method.

I'm no expert on .NET, just learning it on my own(C++.NET only ) when I can.
 

...&&Waiting for the Queen, PMDG!&&ega-GeForce FX5200 128mb DDR AGP8x
IP Logged
 
Reply #2 - Mar 4th, 2005 at 10:40pm

Jared   Offline
Colonel
I'd rather be flying...
Uniontown, Ohio

Gender: male
Posts: 12621
*****
 
allrighty, got it figured out, I had it converted to a string in the following manner...

me.variable1.tostring()
me.variable1.substring(0,1)

that combination does not work..

the following does though.. Wink

me.variable1.text.tostring.substring(0,1)

lol, not sure why it likes it combined better than the other way, but it works this way.. Smiley

Now on to the next problem... Wink

I've got the first portion where we have to convert arabic to roman numbers working without a hitch with strikingly good data validation going for it.

Now the interesting part where I have to convert roman to arabic, WITH data validation...

I kind of have an idea so I'll be busy for a bit.. Wink
 
IP Logged
 
Reply #3 - Mar 8th, 2005 at 12:14am

gw   Offline
Colonel
I love YaBB 1G - SP1!

Posts: 175
*****
 
me.variable1.tostring() converts the value of variable1 to a string and leaves it laying around so another function can use it (on the stack actually).  You haven't changed variable1, itself, to anything.  That's why me.variable1.substring(0, 1) doesn't work.

when you string it altogether as me.variable1.tostring().substring(0,1) you get better results because the output of tostring is a string, of course, and gets passed to substring.

gw




 

Cessna N7654 ready to copy IFR clearance to KSMF.&&&&Cessna N7654 cleared to KSMURF as filed.&&
IP Logged
 
Reply #4 - Mar 9th, 2005 at 11:50am

Ivan   Offline
Colonel
No, I'm NOT Russian, I
only like Russian aircraft
The netherlands

Gender: male
Posts: 6058
*****
 
substring is a function, means that you'll have to assign the result to something

blabla=variable1.substring(0,1) should work
 

Russian planes: IL-76 (all standard length ones),  Tu-154 and Il-62, Tu-134 and An-24RV&&&&AI flightplans and repaints can be found here
IP Logged
 
Reply #5 - Mar 9th, 2005 at 10:21pm

Jared   Offline
Colonel
I'd rather be flying...
Uniontown, Ohio

Gender: male
Posts: 12621
*****
 
allrighty, thanks for the info, perhaps more questions will be coming in future days..Wink
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print