Page 1 of 1

Visual Studio .net 2003

PostPosted: Wed Mar 02, 2005 10:25 pm
by Jared
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..;-)

Re: Visual Studio .net 2003

PostPosted: Fri Mar 04, 2005 8:55 am
by krylite
Do you have the header lines?:

#using
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.

Re: Visual Studio .net 2003

PostPosted: Fri Mar 04, 2005 10:40 pm
by Jared
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.. ;-)

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.. :-)

Now on to the next problem... ;-)

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.. ;-)

Re: Visual Studio .net 2003

PostPosted: Tue Mar 08, 2005 12:14 am
by gw
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

Re: Visual Studio .net 2003

PostPosted: Wed Mar 09, 2005 11:50 am
by Ivan
substring is a function, means that you'll have to assign the result to something

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

Re: Visual Studio .net 2003

PostPosted: Wed Mar 09, 2005 10:21 pm
by Jared
allrighty, thanks for the info, perhaps more questions will be coming in future days..;-)