hi,
is it possible to take multiple values(int) seperated by commas as input from
textbox in C# and draw a figure using those values.
e.g. drawing a simple path using 1,2,3,4 values.

--
Message posted via http://www.dotnetmonster.com

Re: read multiple values from textbox are process them by Peter

Peter
Sat Mar 15 14:14:56 CDT 2008

On Sat, 15 Mar 2008 11:42:57 -0700, smoky_flame via DotNetMonster.com
<u42139@uwe> wrote:

> hi,
> is it possible to take multiple values(int) seperated by commas as input
> from
> textbox in C# and draw a figure using those values.
> e.g. drawing a simple path using 1,2,3,4 values.

Yes, it's possible. As long as you can clearly and precisely define the
problem, there is a solution.

As stated so far, though, I don't think there is one. The biggest problem
is that "drawing a simple path using 1,2,3,4 values" is too vague. How
are the values supposed to be interpreted with respect to describing a
"simple path"?

You can use String.Split() or other mechanisms to separate a single string
that might be contained in a TextBox into individual parts, and of course
you can then use int.TryParse() to parse those parts into numbers. But
then what? How do you expect to use the numbers?

Pete

Re: read multiple values from textbox are process them by Jon

Jon
Sat Mar 15 14:15:04 CDT 2008

smoky_flame via DotNetMonster.com <u42139@uwe> wrote:
> is it possible to take multiple values(int) seperated by commas as input from
> textbox in C# and draw a figure using those values.
> e.g. drawing a simple path using 1,2,3,4 values.

Yes, certainly. Which bit are you having trouble with? Split the job
into several small tasks, and focus on one at a time. If you have a
problem with one particular task, I suggest you ask about that task in
isolation.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Re: read multiple values from textbox are process them by smoky_flame

smoky_flame
Sat Mar 15 14:42:09 CDT 2008

actually im taking input in textboxes. ive done this with single vales as i
used:
if (TextBox4_pa.Text == "1")
{
p1.StartCap = LineCap.ArrowAnchor;
Gfx.DrawLine(p1,200,140,76,80);

}
if (TextBox4_pa.Text == "2")
{
p1.StartCap = LineCap.ArrowAnchor;
Gfx.DrawLine(p1, 210, 140, 190, 50);

}
if (TextBox4_pa.Text == "3")
{
p1.StartCap = LineCap.ArrowAnchor;
Gfx.DrawLine(p1, 210, 140, 160, 110);

}



but i cant do it with values in the textbox like 1,2,3 ....any coding
suggestions or help.?

Jon Skeet [C# MVP] wrote:
>> is it possible to take multiple values(int) seperated by commas as input from
>> textbox in C# and draw a figure using those values.
>> e.g. drawing a simple path using 1,2,3,4 values.
>
>Yes, certainly. Which bit are you having trouble with? Split the job
>into several small tasks, and focus on one at a time. If you have a
>problem with one particular task, I suggest you ask about that task in
>isolation.
>

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-csharp/200803/1


Re: read multiple values from textbox are process them by smoky_flame

smoky_flame
Sat Mar 15 14:43:43 CDT 2008

actually im taking input in textboxes. ive done this with single vales as i
used:
if (TextBox4_pa.Text == "1")
{
p1.StartCap = LineCap.ArrowAnchor;
Gfx.DrawLine(p1,200,140,76,80);

}
if (TextBox4_pa.Text == "2")
{
p1.StartCap = LineCap.ArrowAnchor;
Gfx.DrawLine(p1, 210, 140, 190, 50);

}
if (TextBox4_pa.Text == "3")
{
p1.StartCap = LineCap.ArrowAnchor;
Gfx.DrawLine(p1, 210, 140, 160, 110);

}



but i cant do it with values in the textbox like 1,2,3 ....any coding
suggestions or help.?

Jon Skeet [C# MVP] wrote:
>> is it possible to take multiple values(int) seperated by commas as input from
>> textbox in C# and draw a figure using those values.
>> e.g. drawing a simple path using 1,2,3,4 values.
>
>Yes, certainly. Which bit are you having trouble with? Split the job
>into several small tasks, and focus on one at a time. If you have a
>problem with one particular task, I suggest you ask about that task in
>isolation.
>

--
Message posted via http://www.dotnetmonster.com


Re: read multiple values from textbox are process them by smoky_flame

smoky_flame
Sat Mar 15 14:45:04 CDT 2008

actually im taking input in textboxes. ive done this with single vales as i
used:
if (TextBox4_pa.Text == "1")
{
p1.StartCap = LineCap.ArrowAnchor;
Gfx.DrawLine(p1,200,140,76,80);

}
if (TextBox4_pa.Text == "2")
{
p1.StartCap = LineCap.ArrowAnchor;
Gfx.DrawLine(p1, 210, 140, 190, 50);

}
if (TextBox4_pa.Text == "3")
{
p1.StartCap = LineCap.ArrowAnchor;
Gfx.DrawLine(p1, 210, 140, 160, 110);

}



but i cant do it with values in the textbox like 1,2,3 ....any coding
suggestions or help.?

Jon Skeet [C# MVP] wrote:
>> is it possible to take multiple values(int) seperated by commas as input from
>> textbox in C# and draw a figure using those values.
>> e.g. drawing a simple path using 1,2,3,4 values.
>
>Yes, certainly. Which bit are you having trouble with? Split the job
>into several small tasks, and focus on one at a time. If you have a
>problem with one particular task, I suggest you ask about that task in
>isolation.
>

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-csharp/200803/1


Re: read multiple values from textbox are process them by Jon

Jon
Sat Mar 15 15:48:17 CDT 2008

smoky_flame via DotNetMonster.com <u42139@uwe> wrote:
> actually im taking input in textboxes. ive done this with single vales as i
> used:
> if (TextBox4_pa.Text == "1")
> {
> p1.StartCap = LineCap.ArrowAnchor;
> Gfx.DrawLine(p1,200,140,76,80);
>
> }
> if (TextBox4_pa.Text == "2")
> {
> p1.StartCap = LineCap.ArrowAnchor;
> Gfx.DrawLine(p1, 210, 140, 190, 50);
>
> }
> if (TextBox4_pa.Text == "3")
> {
> p1.StartCap = LineCap.ArrowAnchor;
> Gfx.DrawLine(p1, 210, 140, 160, 110);
>
> }
>
>
>
> but i cant do it with values in the textbox like 1,2,3 ....any coding
> suggestions or help.?

Well, the way I would split the job up is:

1) Obtaining the text from the TextBox (use the Text property)
2) Split the string by commas (use String.Split)
3) Potentially trim each string (use String.Trim)
4) Parse each string (use int.TryParse)
5) Handle each integer (I suspect you should aim for more general
code than the above, e.g. a map or array from number to line
points)

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Re: read multiple values from textbox are process them by smoky_flame

smoky_flame
Sun Mar 16 02:20:41 CDT 2008

im going to do what u said. kindly make me clear he 5th point.

Jon Skeet [C# MVP] wrote:
>> actually im taking input in textboxes. ive done this with single vales as i
>> used:
>[quoted text clipped - 19 lines]
>> but i cant do it with values in the textbox like 1,2,3 ....any coding
>> suggestions or help.?
>
>Well, the way I would split the job up is:
>
>1) Obtaining the text from the TextBox (use the Text property)
>2) Split the string by commas (use String.Split)
>3) Potentially trim each string (use String.Trim)
>4) Parse each string (use int.TryParse)
>5) Handle each integer (I suspect you should aim for more general
> code than the above, e.g. a map or array from number to line
> points)
>

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-csharp/200803/1


Re: read multiple values from textbox are process them by Jon

Jon
Sun Mar 16 02:38:13 CDT 2008

smoky_flame via DotNetMonster.com <u42139@uwe> wrote:
> im going to do what u said. kindly make me clear he 5th point.

Well, your previously posted code has several "if" blocks, with the
same code in each apart from some different numbers.

Encapsulate those numbers in a type, and then you can have an array (or
a Dictionary<int,YourNewType>) so that you don't need if/else - just
use the parsed number to get at the set of numbers directly.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Re: read multiple values from textbox are process them by smoky_flame

smoky_flame
Sun Mar 16 09:56:29 CDT 2008

ive used string.split and it delimited th commas.
but how can i used GDI+ with it?
Jon Skeet [C# MVP] wrote:
>> im going to do what u said. kindly make me clear he 5th point.
>
>Well, your previously posted code has several "if" blocks, with the
>same code in each apart from some different numbers.
>
>Encapsulate those numbers in a type, and then you can have an array (or
>a Dictionary<int,YourNewType>) so that you don't need if/else - just
>use the parsed number to get at the set of numbers directly.
>

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-csharp/200803/1


Re: read multiple values from textbox are process them by Jon

Jon
Sun Mar 16 10:29:45 CDT 2008

smoky_flame via DotNetMonster.com <u42139@uwe> wrote:
> ive used string.split and it delimited th commas.

And have you parsed the strings into integers?

> but how can i used GDI+ with it?

Well, you really haven't given nearly enough details as to what you
want to actually *do* with the numbers when you've parsed them. You've
given an example, but it doesn't explain where the points defining the
lines have come from. You'll need to work that out yourself.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Re: read multiple values from textbox are process them by Peter

Peter
Sun Mar 16 13:00:06 CDT 2008

On Sun, 16 Mar 2008 00:20:41 -0700, smoky_flame via DotNetMonster.com =

<u42139@uwe> wrote:

> im going to do what u said. kindly make me clear he 5th point.

As an example of one possible implementation of "the 5th point":

Instead of all those if() statements you posted in previous code, you =

could encapsulate that information as an array:

Point[][] pointPairs =3D { { new Point(0, 0), new Point(200, 140) }=
,
{ new Point(200, 140), new Point(76, 80) }=
,
{ new Point(210, 140), new Point(190, 50) =
},
{ new Point(210, 140), new Point(160, 110)=
} =

};

Then you can draw the lines like this:

int ipair;

if (int.TryParse(TextBox4_pa.Text, out ipair))
{
Point[] pointPair =3D pointPairs[ipair];

p1.StartCap =3D LineCap.ArrowAnchor;
Gfx.DrawLine(p1, pointPair[0], pointPair[1]);
}
else
{
// handle error
}

Of course, in your actual code you'd also incorporate the splitting =

technique described, presumably in a loop where you process all of the =

resulting strings.

Pete

Re: read multiple values from textbox are process them by Martin

Martin
Tue Mar 18 06:40:25 CDT 2008

On Mar 15, 7:14 pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
> On Sat, 15 Mar 2008 11:42:57 -0700, smoky_flame via DotNetMonster.com
>
> <u42139@uwe> wrote:
> > hi,
> > is it possible to take multiple values(int) seperated by commas as input
> > from textbox in C# and draw a figure using those values.
> > e.g. drawing a simple path using 1,2,3,4 values.
>
> Yes, it's possible.
Agreed

> As long as you can clearly and precisely define the
> problem, there is a solution.

Not necessarily. Counter example: "Specify an algorithm to decide if
an arbitrary Turing machine will halt".

... however, I agree that the OP's main problem is a lack of clarity
in the specification rather than a fundamentally insoluble problem.


Re: read multiple values from textbox are process them by Peter

Peter
Tue Mar 18 14:46:36 CDT 2008

On Tue, 18 Mar 2008 04:40:25 -0700, Martin Bonner
<martinfrompi@yahoo.co.uk> wrote:

> [...]
>> As long as you can clearly and precisely define the
>> problem, there is a solution.
>
> Not necessarily. Counter example: "Specify an algorithm to decide if
> an arbitrary Turing machine will halt".

Forgive me for assuming that my statement would have been considered in
the context of this thread, rather than so generally. I'm not sure what
stating the obvious adds to this thread, but as long as you see the value
I guess it doesn't hurt anything.

Pete