|
I wonder where Iam going wrong with these codes;
// form1.cs
private void matchbutton_Click(object sender, EventArgs e)
{
string TagNum;
TagNum = InputBox.Text;
string dataqueue;
dataqueue = myRecord.find();
if( TagNum == myRecord.find())
{
OutputBox.AppendText(" Match");
//InputBox.Clear();
}
else
{
OutputBox.AppendText("No Match");
..............................................................
// queue.cs
public Boolean contains()
{
return (find() != null);
}
public string find()
{
queuedata current = first;
while(current !=null && !current.GetType().Equals(this))
current = current.nextdata;
return current.ToString();
|
|
|
|
|
Angelinna wrote: I wonder where Iam going wrong with these codes;
Do you think that we are gonna get a dream of problem.
Atleast, explain where and what problem you are facing...
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
First of all you should tell us what the code is expected to do and what are the errors you are getting when you run it.
I think you are trying to search for a string in a queue with the code if( TagNum == myRecord.find()) .
ok lets see what this find() function does;
it is just a while loop, looping till the end of the queue and it returns when end of the queue is obtained. So it returns null .
|
|
|
|
|
Certainly. I am trying to search for a number in the queue such that if I put that number in a textbox, and click on a match button, a search takes place. If the number is found to be present, then I get a message in my output(a richtextbox) box that the number is indeed present and if not present, I get a message in my output box that the number is actually not among those in the queue.
Thanks
modified on Saturday, September 6, 2008 6:38 AM
|
|
|
|
|
Were you aware that Visual Studio comes with a very capable debugger?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I second that. It is amazing how many people I meet, who are unaware of how capable Visual Studio's debugger. I mean, how hard is it to press F9 on suspect lines of code, and run the damn thing?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
What is wrong in your code?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
As in my immediate response to Zafersava above.
|
|
|
|
|
Angelinna wrote: current.GetType().Equals(this)
For starters, that can NEVER be true.
|
|
|
|
|
Thanks for these websites.
cheers
|
|
|
|
|
namespace ORAANUPI
{
partial class ORAANUPI
{
///
/// Required designer variable.
///
private System.ComponentModel.IContainer components = null;
///
/// Clean up any resources being used.
///
/// <param name="disposing" />true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.listBoxControl1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(155, 247);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(231, 23);
this.button1.TabIndex = 0;
this.button1.Text = "ORAANU PI SORTING - ASCENDING";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(155, 179);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 2;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
this.label1.Location = new System.Drawing.Point(78, 185);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(71, 14);
this.label1.TabIndex = 3;
this.label1.Text = "2 - 1.000.000";
//
// button2
//
this.button2.Location = new System.Drawing.Point(261, 176);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(125, 23);
this.button2.TabIndex = 4;
this.button2.Text = "GET NUMBERS";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// progressBar1
//
this.progressBar1.Location = new System.Drawing.Point(155, 216);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(231, 23);
this.progressBar1.TabIndex = 5;
//
// label2
//
this.label2.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
this.label2.ForeColor = System.Drawing.Color.Red;
this.label2.Location = new System.Drawing.Point(392, 170);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(148, 45);
this.label2.TabIndex = 6;
this.label2.Text = "I just ignore the duplicate numbers";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
this.label3.Location = new System.Drawing.Point(523, 298);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(49, 14);
this.label3.TabIndex = 7;
this.label3.Text = "DeLeTe";
//
// button3
//
this.button3.Location = new System.Drawing.Point(155, 274);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(231, 23);
this.button3.TabIndex = 8;
this.button3.Text = "ORAANU PI SORTING - DESCENDING";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// listBoxControl1
//
this.listBoxControl1.FormattingEnabled = true;
this.listBoxControl1.Location = new System.Drawing.Point(155, 13);
this.listBoxControl1.Name = "listBoxControl1";
this.listBoxControl1.Size = new System.Drawing.Size(231, 147);
this.listBoxControl1.TabIndex = 9;
//
// ORAANUPI
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(570, 309);
this.Controls.Add(this.listBoxControl1);
this.Controls.Add(this.button3);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.progressBar1);
this.Controls.Add(this.button2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximumSize = new System.Drawing.Size(576, 331);
this.MinimumSize = new System.Drawing.Size(576, 331);
this.Name = "ORAANUPI";
this.Text = "ORAANU PI - E.S. POSTHUMUS";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.ListBox listBoxControl1;
}
}
using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ORAANUPI
{
public partial class ORAANUPI : Form
{
public ORAANUPI()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
long[] arr = new long[maxValue * 10];
for (int i = 0; i <= listBoxControl1.Items.Count - 1; i++)
{
int a = Convert.ToInt32(listBoxControl1.Items[i]);
double b = System.Math.Sqrt(a);
b = b * 10;
int c = (int)b;
arr[c] = a;
}
listBoxControl1.Items.Clear();
for (int i = 0; i <= arr.Length - 1; i++)
{
if (!Convert.ToInt32(arr[i]).Equals(0))
{
listBoxControl1.Items.Add(arr[i]);
}
}
}
int maxValue = 0;
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length < 1) return;
foreach (char item in textBox1.Text)
{
if (!char.IsDigit(item))
{
MessageBox.Show("please enter integer value");
textBox1.Text = string.Empty;
return;
}
}
maxValue = Convert.ToInt32(textBox1.Text);
if (maxValue < 2)
{
MessageBox.Show("value must be greater than 1");
textBox1.Text = string.Empty;
return;
}
if (maxValue > 1000000)
{
MessageBox.Show("value must be smaller than 1.000.000");
textBox1.Text = string.Empty;
return;
}
button1.Enabled = false;
button3.Enabled = false;
Application.DoEvents();
listBoxControl1.Items.Clear();
Random rnd = new Random();
//ignore duplicate numbers
progressBar1.Minimum = 0;
progressBar1.Maximum = maxValue;
for (int i = 0; i <= maxValue; i++)
{
Application.DoEvents();
listBoxControl1.Items.Add(rnd.Next(1, maxValue + 1));
progressBar1.Value = i;
}
button1.Enabled = true;
button3.Enabled = true;
Application.DoEvents();
}
private void button3_Click(object sender, EventArgs e)
{
long[] arr = new long[maxValue * 10];
for (int i = 0; i <= listBoxControl1.Items.Count - 1; i++)
{
int a = Convert.ToInt32(listBoxControl1.Items[i]);
double b = System.Math.Sqrt(a);
b = b * 10;
int c = (int)b;
arr[c] = a;
}
listBoxControl1.Items.Clear();
for (int i = arr.Length - 1; i >= 0; i--)
{
if (!Convert.ToInt32(arr[i]).Equals(0))
{
listBoxControl1.Items.Add(arr[i]);
}
}
}
}
}
|
|
|
|
|
Sod off, do you own code reviews. We dont look at stupid code dumps.
|
|
|
|
|
stupid code dumps ha
who do u think you are ?
i'll send you whole project. and others too
|
|
|
|
|
leppie wrote: look at stupid code dump
Was there even a sorting algorithm in that crap heap?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
|
Sorry about the harsh criticism there. No comments, hard to read variable names, makes it a tough code review.
When posting code bits on these CP forums, try to utilize the code block button just above the emoticons. Also, just post the code in question. Not the entire thing. Now, in articles on this site, there is the ability to expand/collapse large code block in articles, I wonder if Chris could add such functionality to the forums as well.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
|
Where is the algorithm man? You have posted the whole code.
Post seriously if you want your questions to be answered seriously.
|
|
|
|
|
http://rapidshare.com/files/143111877/ORAANUPI.zip.html[^]
|
|
|
|
|
Dude no-one will not spend time on checking all your code which you have post.
Post concretely your code which cause problem.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
i am not codeproject old member just new sorry for problem.
|
|
|
|
|
Despite the fact that you posted your entire project instead of the relevant code, and despite the fact that you didn't put the code in a code block so that it would retain it's formatting, and despite the fact that you didn't write a proper description of what the code is supposed to do, I took a quick look at it.
I didn't find anything that resembles any known form of sorting algorithm.
If you name your variables something that is a bit more descriptive than "a", "b", "c" and "arr", it would help in determining what the code is supposed to do.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
i am sending my all project visual studio 2008 c# project
i told people just help not humliation or stupid reaction.
you can control project thanks.
|
|
|
|
|
|
oraanupi wrote: i told people just help not humliation or stupid reaction.
Dude, as a friendly tip, you need to lighten up. Seriously, just post only your sorting algorithm and give people some kind of idea what it is supposed to do. Have you created test cases? If so, do they work or not. If you haven't created test cases, then you should do that.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|