|
|
Please don't repost so quickly. It's generally considered to be quite rude.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
You've been told once already: Do your own homework?
We are willing to help if you show what you have tried to do and then we can help to show you where you went wrong and how to fix it. However, you have not shown any attempt at the problem that you are having difficulty with yet.
|
|
|
|
|
That code does not represent the problem. For a start your problem statment requires TWO inputs. Where is the other one?
|
|
|
|
|
Gotta love people who delete all their posts.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: Gotta love people who delete all their posts.
Yep, now I am very curious to what it was. That is why I usually highlight the post in my reply, so it is there even if they delete theirs
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
dianenacario wrote: How can I modify this?
console.write("input integer:");
int i= int.parse(console.raedline());
int x=1;
for(int y=1; y=i; y++)
{
x=x*y;
}
console.write(x)
console.readkey();
This does not even fulfil the requirement before specification that the * operator is not to be used. It quite specifically states that the program must take 2 user inputs. Yours only takes 1.
Change this to take 2 inputs and get it working using the * operator. You will at least get partial credit even if you cant work out how to get the 2nd loop to do the job of the * operator.
Aside from that, requirements like this are not too dissimilar in the real world. Albeit that we don't ban the use of a particular operator, sometimes constraints are placed on you that you must adhere to. This goes for all jobs - not just programming.
|
|
|
|
|
Rather than go in the huff and delete your posts you might want to try and address your problems.
|
|
|
|
|
Colin Angus Mackay wrote: go in the huff and delete your posts
At least J4amieC has part of the original post in his reply It sounded like homework.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
|
That was the impression I got from J4amieC's reply
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I want to write code on textchanged event for rich text box, such that user can specify the no. of chracters in a single line, and according to that the word wraps.
Plz help me
|
|
|
|
|
|
The code is working but with some problem?
If user inputs some lines and come back to previous line, like editing the text, then problem occurs like its overwriting.
Ex line:"1. This Code is giving me much problem as i m fresher."
like this user enter 3-4 lines or paragraph?
Now if user comes back to 1 line and edit, its messed up like:
"1. This code hai s giving me much problem as i m fresher."
Here i try to enter have after code.
Plz help.
private void txtBody_TextChanged(object sender, eventArgs e)
{
if(tbWordwrap.Pushed)
{
string[] tempArray = new string(txtBody.Lines.length);
tempArray = txtBody.Lines;
int Prevsel = txtBody.SelectionStart;
string Op = "";
int maxLength = cINI.dbUtils.Pref.DefaultEditorWidth;
bool change= false;
for(int cou = 0; cou < tempArray.Length ; cou++)
{
if (tempArray[cou].length > maxLength)
{
string words = tempArray[cou].split(' ');
int currentLine Length = 0;
string currentLine = "";
foreach(string currentWords in words)
{
if(currentWord.Length > 0)
{
if(currentword.Length >= maxLength)
{
Op += currentword.Insert(maxLength, "\r\n");
break;
}
if(currentLineLength + currentword.Length + 1 < maxLength)
{
currentLine += currentword + " ";
currentLineLength += currentword.Length +1;
}
else
{
Op +=currentLine.Insert(currentLineLength, "\r\n");
currentLine = currentWord;
currentLineLength = currentWord.Length;
}
}
}
if(currentLine !="")
Op += currentLine;
PrevSel++;
change = true;
}
else
{
Op += tempArray[cou] + "\r\n";
}
if(change)
{
txtBody.Text = Op;
txtBody.SelectionStart = prevSel;
}
}
}
The above code is for text_change event of RichText Box in C# vs.net 2003.
|
|
|
|
|
Hi,
1.
what is this? the code does not compile at all, it is full of mistakes.
C# is case-sensitive, what are currentWords, currentWord and currentword ??
.NET methods start with an upper-case, there is no string.split, no string.length.
2.
the algorithm is flawed. If you insert in the middle of a line, the last word
would get moved to the next line; if you keep inserting, another word would
get moved to the next line; in the end all the words are on separate lines.
You can't do proper word wrapping without recombining words to lines.
But then you also need a way to indicate the start a new paragraph.
3.
A TextBox has built-in support for word wrapping; I guess it will function a lot
better than anything you will come up with any time soon.
Goodbye.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
With all respect sir plz,
The thing is its a very small firm in which i m working, & have no senior to help. on my own i tried every possible way,
All is fine(Acc. to me), only the editing or modifying the text creates problem.
if user enter 3-4 lines:
"This is trial message plz ignore.
This is trial message plz ignore.
This is trial message plz ignore.
This is trial message plz ignore."
and now when user comes back to first line and enter some data in between, then the problem starts,
plz sir
private void txtBody_TextChanged(object sender, System.EventArgs e)
{
#region "wrap"
string[] tempArray = new string [txtBody.Lines.Length];
tempArray = txtBody.Lines;
int PrevSel = txtBody.SelectionStart;
string Op = "";
int maxLength = Convert.ToInt32(textBox1.Text);
bool change= false;
for(int cou = 0; cou < tempArray.Length ; cou++)
{
if (tempArray[cou].Length > maxLength)
{
string[] words = tempArray[cou].Split(' ');
int currentLineLength = 0;
string currentLine = "";
foreach(string currentWord in words)
{
if(currentWord.Length >= 0)
{
if(currentWord.Length >= maxLength)
{
Op += currentWord.Insert(maxLength, "\r\n");
break;
}
if(currentLineLength + currentWord.Length + 1 < maxLength)
{
currentLine += currentWord + " ";
currentLineLength += currentWord.Length +1;
}
else
{
Op +=currentLine.Insert(currentLineLength, "\r\n");
currentLine = currentWord + " ";
currentLineLength = currentWord.Length;
}
}
}
if(currentLine !="")
Op += currentLine;
PrevSel++;
change = true;
}
else
{
Op += tempArray[cou] + "\r\n";
}
if(change)
{
txtBody.Text = Op;
txtBody.SelectionStart = PrevSel;
}
}
#endregion
}
|
|
|
|
|
You do know that people are going to tell you that you should do your homework yourself don't you?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I have date in the format dd/mm/yyyy and I want to convert it to mm/dd/yyyy fromat as DateTime datatype,
I hope you understood the problem, please help me in solving this...
Prahsant V C
|
|
|
|
|
try to use DateTime.Parse(...);
|
|
|
|
|
And I need a hand in this
tree_Level.Nodes.Clear();
for (int x = 0; x < dataSet1.COMMS.Rows.Count; x++)
{
tree_Level.Nodes.Add(dataSet1.COMMS.Rows[x]["COMM_NAME"].ToString() + "_" + dataSet1.COMMS.Rows[x]["COMM_ID"].ToString(), dataSet1.COMMS.Rows[x]["COMM_NAME"].ToString(), 0, 0);
for (int y = 0; y < dataSet1.UZL.Rows.Count; y++)
{
if (dataSet1.UZL.Rows[y]["UZ_COMM_ID"].ToString() == dataSet1.COMMS.Rows[x]["COMM_ID"].ToString())
{
tree_Level.Nodes[x].Nodes.Add(dataSet1.UZL.Rows[y]["UZ_NAME"].ToString() + "_" + dataSet1.UZL.Rows[y]["UZ_ID"].ToString(), dataSet1.UZL.Rows[y]["UZ_NAME"].ToString(), 1, 1);
for (int z = 0; z < dataSet1.VILS.Rows.Count; z++)
{
if (dataSet1.VILS.Rows[z]["VIL_UZ_ID"].ToString() == dataSet1.UZL.Rows[y]["UZ_ID"].ToString())
tree_Level.Nodes[x].Nodes[0].Nodes.Add(dataSet1.VILS.Rows[z]["VIL_NAME"].ToString() + "_" + dataSet1.VILS.Rows[z]["VIL_ID"].ToString(), dataSet1.VILS.Rows[z]["VIL_NAME"].ToString(), 2, 2);
}
}
}
}
The last level in the loop is not doing fine (it puts all the second level subordinates under one node that is the first node in level two
ps. I know it's a mess but please just focus on the two inner nested loops.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
It's failing because you are assigning your new node at Nodes[x].Nodes[0] which will always be the same node under [x]. To get round this, change it to Nodes[x].Node[y], or better still maintain this via explicit TreeNodes.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks a bunch pete
Pete O`Hanlon wrote: explicit TreeNodes.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Muammar© wrote: Pete O`Hanlon wrote:
explicit TreeNodes.
TreeNode outerNode = new TreeNode("MyValue");
tree_list.Nodes.Add(outerNode);
TreeNode innerNode = new TreeNode("Inner item");
outerNode.Nodes.Add(innerNode);
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi my name is Zahid. Is it possible to use gSOAP with C#? If yes then please tell me how.
|
|
|
|
|
Hi,
I want to add facility to Cab and UnCAB files from my application being developed in c# 2005. how can i archive this. ?? please help..
thnks
|
|
|
|