473,785 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

read multiple values from textbox are process them

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

Mar 15 '08 #1
8 3898
On Sat, 15 Mar 2008 11:42:57 -0700, smoky_flame via DotNetMonster.c om
<u42139@uwewrot e:
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
Mar 15 '08 #2
actually im taking input in textboxes. ive done this with single vales as i
used:
if (TextBox4_pa.Te xt == "1")
{
p1.StartCap = LineCap.ArrowAn chor;
Gfx.DrawLine(p1 ,200,140,76,80) ;

}
if (TextBox4_pa.Te xt == "2")
{
p1.StartCap = LineCap.ArrowAn chor;
Gfx.DrawLine(p1 , 210, 140, 190, 50);

}
if (TextBox4_pa.Te xt == "3")
{
p1.StartCap = LineCap.ArrowAn chor;
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.c om
http://www.dotnetmonster.com/Uwe/For...sharp/200803/1

Mar 15 '08 #3
actually im taking input in textboxes. ive done this with single vales as i
used:
if (TextBox4_pa.Te xt == "1")
{
p1.StartCap = LineCap.ArrowAn chor;
Gfx.DrawLine(p1 ,200,140,76,80) ;

}
if (TextBox4_pa.Te xt == "2")
{
p1.StartCap = LineCap.ArrowAn chor;
Gfx.DrawLine(p1 , 210, 140, 190, 50);

}
if (TextBox4_pa.Te xt == "3")
{
p1.StartCap = LineCap.ArrowAn chor;
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

Mar 15 '08 #4
actually im taking input in textboxes. ive done this with single vales as i
used:
if (TextBox4_pa.Te xt == "1")
{
p1.StartCap = LineCap.ArrowAn chor;
Gfx.DrawLine(p1 ,200,140,76,80) ;

}
if (TextBox4_pa.Te xt == "2")
{
p1.StartCap = LineCap.ArrowAn chor;
Gfx.DrawLine(p1 , 210, 140, 190, 50);

}
if (TextBox4_pa.Te xt == "3")
{
p1.StartCap = LineCap.ArrowAn chor;
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.c om
http://www.dotnetmonster.com/Uwe/For...sharp/200803/1

Mar 15 '08 #5
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.c om
http://www.dotnetmonster.com/Uwe/For...sharp/200803/1

Mar 16 '08 #6
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.c om
http://www.dotnetmonster.com/Uwe/For...sharp/200803/1

Mar 16 '08 #7
On Sun, 16 Mar 2008 00:20:41 -0700, smoky_flame via DotNetMonster.c om
<u42139@uwewrot e:
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 = { { 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(T extBox4_pa.Text , out ipair))
{
Point[] pointPair = pointPairs[ipair];

p1.StartCap = LineCap.ArrowAn chor;
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
Mar 16 '08 #8
On Mar 15, 7:14 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Sat, 15 Mar 2008 11:42:57 -0700, smoky_flame via DotNetMonster.c om

<u42139@uwewrot e:
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.

Mar 18 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
43955
by: Roland Hall | last post by:
Is there a way to return multiple values from a function without using an array? Would a dictionary object work better? -- Roland Hall /* This information is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. */ Technet Script Center - http://www.microsoft.com/technet/scriptcenter/ WSH 5.6 Documentation -...
12
2183
by: Clifford Stern | last post by:
In a function that returns two values, how do you read them? Consider the following function: int addsub(int x,int y) {int a,b; a=x+y; b=x-y; return(a,b);} trying to read the results, for example by g,h=addsub(m,k) only gets the
1
1762
by: samir dsf | last post by:
hi i can send and retrieve a single value. but now i have around 3-4 values which i want to pass, from a link and receive in another page. here is how i am currently doing: Dim urlParams As String = "CallId=" + row("CALLID").ToString() Dim tabid2 As Int32 = 172 e.Item.Cells(0).Text = "<A href='" & DotNetNuke.Common.Globals.NavigateURL(tabid, "", urlParams) & "'
5
7538
by: JenHu | last post by:
Hi experts, I wrote a function which retrieves a file in the folder, the file path is : Dim sr As New StreamReader(strFilepath & ReturnFileName) What if I have more than 1 file_name in EPay_Batch_Table Where File_Status=2? How to read multiple files and 1 file at a time, through a loop?
9
10915
by: Karl O. Pinc | last post by:
I want to return multiple values, but not a set, only a single row, from a plpgsql function and I can't seem to get it to work. (I suppose I'd be happy to return a set, but I can't seem to make that work either. Anyway, what's wrong with this?) Version is: $ rpm -q postgresql
1
1882
by: Rama Jayapal | last post by:
hi i am developing a web application where i have to read multiple XML feeds amd store their values to database but i require the same type of fields from multiple XML feeds like for example
0
854
by: waterfall | last post by:
Hi, Im developing a C# web application in VS2005. Ive 2 textboxes for user input and a button. First textbox gets string as input(e.g, ItemA, ItemB etc.) Second textbox get int as input(1,2,3,4 etc).Button is meant to generate a diagram using GDI. Here is a look at my form. Item1 ----------- Preceding Item 1 ----------- Item 2 ------------ Preceding Item2 ---------- Item3 ----------- Preceding Item 3 ------------ ...
2
3676
ADezii
by: ADezii | last post by:
The incentive for this Tip was an Article by the amazing Allen Browne - I considered it noteworthy enough to post as The Tip of the Week in this Access Forum. Original Article by Allen Browne Traditionally, one has always thought that Functions can only return a single value, and for the most part that was true. Ever since Access 95, we gained the new functionality, through VBA, to have Functions return an entire Structure of values. A User...
0
3106
by: Maric Michaud | last post by:
Le Thursday 28 August 2008 03:43:16 norseman, vous avez écrit : Disctionaries are hash tables with a unique key and constant time lookup. What you want could be implemented as a complex data structures with as many dict as needed keys, but it seems you really want a relational table and a rdbms. This is exactly what they are for. A short example with the new python2.5 sqlite package :
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3646
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.