|
i know this keyword(return) but this keyword use in function,i need like this keyword in method
example
public void f()
{
1: command (Execute
2: Command (Execute
exit sub (in vb.net) (what i can write here like this code in c#)
3: Command (not Execute
4: Command (Not Execute
}
123
|
|
|
|
|
Suppose we have two form. FormA and FormB. FormA has a button. i want when i click the button then Form2 would be open and at that time FormA should be Dispose. but how i dispose FormA?
button click event:
Form2 oForm2=new Form2();
oForm2.ShowDialog();
this.Dispose();
but this code could not dispose the FormA.
Pls help me on this.
|
|
|
|
|
Hello,
You have to use the Show Method instead of ShowDialog.
and then Close (will call the Dispose method also) the FormA.
Form2 oForm2=new Form2();
oForm2.Show();
this.Close();
Does not work if FormA is your main form. Because then your program will end and all forms will be closed.
All the best,
Martin
|
|
|
|
|
|
Instead, you should create both forms as control, and put them both on the one form, showing one at a time.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
sorry, i can't get your point.
|
|
|
|
|
Create two user controls. Design each to look like one of the forms you need. Put both on a form. Alternate which one is Visible to decide which 'form' is showing.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
Guys,
consider following code:
byte [] bytes = new byte[160];
FillBytes(ref bytes);
System.Net.IPAddress ipaddress = new System.Net.IPAddress(1684300900);
System.Net.IPEndPoint ipendpoint = new System.Net.IPEndPoint(ipaddress, 7000);
udpclient = new UdpClient();
try{
int sent = 0;
sent = udpclient.Send(bytes, bytes.Length, SystemInformation.ComputerName, 7000);
MessageBox.Show(Encoding.ASCII.GetString(bytes));
lbl_bytessent.Text = "Sent: " + sent;
}
catch(Exception ex){
MessageBox.Show("send result: error: " + ex.Message);
}
PS: I left the comments to show what I've already tried
I need to send some bytes to a receiving application. I have a small example in VB6 where it seems to work, so I tried in C# to do the same. The bytes that are sent (is set in integer sent) is always correct, the function doesn't come in the catch. However, the receiving application does not seem to react, but it does so with the VB6 application. I'm guessing I need to set some relation between sender and receiver, but I can't figure out how.
Any help on this? According to the examples on MSDN, I'm quite correct?
Thanks !
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
hi,
i am having Form1,Form2,and Form3
In Form2 i am having some values like selecting a radioButton,check box,or entering some text in the textboxes.
then i will be moving to Form3..
Now how can i Save the content of Form2..
if i come back from Form3 to Form2 i should load my values..
Help me pls
With Regards
prasad
|
|
|
|
|
First, please tell me they are not called that...
The easiest way to do this is to make your forms controls within the one form, and change which one is visible. If Form2 disappears when Form3 shows, that's the best way to approach that, in general. The other way to do it, is to just hide Form2, instead of destroying it.
The controls approach is nicer.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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: ForumC#
Subject:Re: Windows Forms
Sender:Christian Graus
Date:9:35 27 Mar '07
First, please tell me they are not called that...
|
|
|
|
|
Hello,
You could hold the Form2 instance in memory (Hide), instaed of disposing (Close) every time you change to ann other form.
All the best,
Martin
|
|
|
|
|
Hello All
i am trying to read a large txt files -may 1 GB-, which coze my program to hang, and i need to know if there are techniques that make this without hang and do it faster
if you know something can help. please tell me.
|
|
|
|
|
The best thing is to avoid such files. You *can* read a file a line at a time, but I'm not sure if it loads in to memory anyhow when you do that. I'd hope not. What code are you using right now ? What is in the files ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
Hi
You could consider using a backgroundworker to read the file, while showing a "loading" sign or something..
basically something like:
private void getTextFileWorker_DoWork(object sender, DoWorkEventArgs e)
{
//start to read the file, show loading sign...
while(morelinesinfile)
{
this.Invoke(new AddValueDelegate(AddValue), new object[] { valueFromFile });
}
}
private void AddValue(string valueFromFile)
{
//do something with the value, add it to a list...
}
private void getTextFileWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//finish up etc..hide sign..
}
best regards
HV
|
|
|
|
|
I suspect the real issue is that 1 GB of text will, on most computers, mean your RAM is full and you're using virtual memory.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
that is my code , and i had run it for a txt file its size is 423 MB, and i left my PC opened and in the mext day i found that it records about 10 hours and large number of lines about 500000 line and also i got an exception "OutOfMemoryException"
and i dont know much about "backgroundworker", if you know a complete example plz provid me by the link
StreamReader SR;
private void btnReadFile_Click(object sender, EventArgs e)
{
DateTime DT= DateTime.Now;
TimeSpan T = new TimeSpan(DT.Day, DT.Hour, DT.Minute, DT.Second);
if (SR != null)
{
while (!SR.EndOfStream)
{
try
{
string line = SR.ReadLine();
txtFileContent.AppendText(line);
txtFileContent.AppendText("\n");
txtFileContent.AppendText("\r");
int count = Convert.ToInt32(labNumOfLines.Text);
count++;
labNumOfLines.Text = count.ToString();
DateTime tempTime = DateTime.Now;
TimeSpan T2 = new TimeSpan(tempTime.Day, tempTime.Hour, tempTime.Minute, tempTime.Second);
T2=T2.Subtract(T);
labTime.Text = T2.ToString();
this.Refresh();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
|
|
|
|
|
Is txtFileContent a string or a StringBuilder ? IF the former replacing it with the latter will see a massive performance boost. A string is immutable, which means each time you do txtFileContent.AppendText(line); you're creating a new string and copying the old one to it. For normal use immutable strings allow certain optimizations that result in faster code, but when building a really large string they absolutely murder performance. IF you;re using a string for each line of your file you're copying everything read so far three times. And absolutely thrashing the GC in the process.
--
CleaKO The sad part about this instance is that none of the users ever said anything [about the problem].
Pete O`Hanlon Doesn't that just tell you everything you need to know about users?
|
|
|
|
|
txtFileContent is a textBox
|
|
|
|
|
That almost certainly uses a string internally. Load the entire thing into a stringbuilder first and then copy when complete. Even then I seriously doubt the tb is capable of handling that large a string in a managable fashion.
--
CleaKO The sad part about this instance is that none of the users ever said anything [about the problem].
Pete O`Hanlon Doesn't that just tell you everything you need to know about users?
|
|
|
|
|
Also if the file is order or can be ordered access it in that manner. Ie, Binary Searches, index based searches, etc. I have worked with several multi gig files in the past and that is the only hope.
File Not Found
|
|
|
|
|
Hi all,
I am working on a school project in c#. It was going good so far but now I have to convert a Motorola S-record file to a Binary file. I know the layout of the S-record file. But I have no idea how to convert this to a binary file (using c#). I hope anyone can help me with this problem.
I have found some anwsers on the internet but the source code didn't fit the c# context.
|
|
|
|
|
-=gix=- wrote: I know the layout of the S-record file. But I have no idea how to convert this to a binary file
What part are you stuck on? You know the format of the input file, do you know how to read it? What is the format of the binary file? (You didn't mention that) And once you know the format of the output, do you know how to write that?
There is also the translation aspect, do things need to be re-ordered between input and output? Or is the translation a direct text based data to binary based data?
|
|
|
|
|
I know how to read the S-record, but the problem is that I have no idea how a binary file looks like (the format). If I know this, I will be able to write it.
further information:
The binary file is used for a MCU (Micro Controller Unit) on an ARM processorboard.
|
|
|
|
|
-=gix=- wrote: but the problem is that I have no idea how a binary file looks like (the format).
Then you need to find out the format before we can help. There are thousands, if not millions, of possible binary formats.
|
|
|
|