|
Dothanhnam wrote: public static Form[] listFormChoose;
You are not initializing array try something like
public static Form[] listFormChoose = new Form[4];
|
|
|
|
|
Thank you, but when I rewrite follow you, has a error :Index was outside the bounds of the array. Can you help me!
|
|
|
|
|
This means that the values of i and j that are used as array indexes are getting to big. Arrays have a null-based index, so if your array has four elements those are accessible via indexes 0, 1, 2 and 3.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I've been making a calculator that i can include in apps that may need one (for convenience)
But ive come accross a slight problem. I have it in hex mode, i type in FF, i use the not operator, i get FFFFFFFFFFFFF00. So all is good.
I do this by converting the hex FF, into a ulong (or UInt64). But when i try to use the NOT again, it goes to FFFFFFFFFFFFFFFF, this is because:
FFFFFFFFFFFFF00 = 18446744073709551360
and NOT 18446744073709551360 = -18446744073709551361
See nows there's the problem, ulong has no negatives. And im way to tired to think anymore. So any unput would be real good. Thanks.
|
|
|
|
|
How are you implementing the not operator?
The following short console program does what you want:
using System;
using System.Collections.Generic;
using System.Text;
namespace NotTest
{
class Program
{
static void Main(string[] args)
{
ulong i = 0xFF;
Console.WriteLine(i);
i = ~i;
Console.WriteLine(i);
i = ~i;
Console.WriteLine(i);
Console.Read();
}
}
}
With the output:
255
18446744073709551360
255
If you're getting negative output, it's gotta be because the unsigned long is being converted to a signed long somewhere along the way.
|
|
|
|
|
Its not my calcy that gave the negative value, that would be the windows calculator.
I'll just see if I can figure it out tomorrow. It's probably something incredible simple.
Well, must sleep now.
|
|
|
|
|
Hello everyone,
I have a String and would like to be able to pick let's say First, Second, and the Last letter and create a new string.
Can someone be kind enough to tell me how I can get this done?
Thank you so much and have a great day.
Khoramdin
|
|
|
|
|
str[0] + str[1] + str[str.Length-1]
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 )
|
|
|
|
|
You can use..
String str = "abc";
foreach (char c in str)
{
// operations on letters.
}
"If our Mind can, the Program can !!"
|
|
|
|
|
Here is code that I found on page 85 of Microsoft Visual C# 2005 Step by Step, I need some further explanation on the line "current = digit + current;" This line seems to concatenate a string and char value, but the book has only a vague exlanation. Could anyone explain further? Here is the code.
#region Using directives
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
#endregion
namespace DoStatement
{
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void showSteps_Click(object sender, System.EventArgs e)
{
int amount = System.Int32.Parse(number.Text);
steps.Text = "";
string current = "";
do
{
int digitCode = '0' + amount % 10;
char digit = Convert.ToChar(digitCode);
// on first iteration result will be 3,
// but that what current was before adding.
current = digit + current;
steps.Text += current + "\r\n";
amount /= 10;
}
while (amount != 0);
}
}
}
Steven Fried
|
|
|
|
|
netproblemsolver wrote: This line seems to concatenate a string and char value
yes, that's exactly right. You can also add a string and an int, and get a string, the framework works out that this is what you're after.
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 )
|
|
|
|
|
I’m feeling really stupid. I have to thread a Form (with a webbrowser), then I have to call a save method after a while.
my code...
Namespace MyLib
{
public delegate String DelegateCopyToFile();
public class MyControl
{
public MyWindow MyInterface;
ThreadStart My_start;
Thread MyThread;
…
public MyControl
{
My_start = new ThreadStart(StartBrowser);
MyThread = new Thread(My_start);
MyThread.SetApartmentState(ApartmentState.STA);
MyThread.Start();
}
public void StartBrowser()
{
MyInterface = new MyWindow();
MyInterface.Show();
}
public string SaveNow()
{
return MyInterface.dCopyMyFile();
}
}
public partial class MyWindow : Form
{
public DelegateCopyToFile dCopyMyFile;
public MyWindow()
{
…
dCopyMyFile = new DelegateCopyToFile(this.SaveFile2);
}
public string Namespace MyLib
{
public delegate String DelegateCopyToFile();
public class MyControl
{
public MyWindow MyInterface;
ThreadStart My_start;
Thread MyThread;
…
public MyControl
{
My_start = new ThreadStart(StartBrowser);
MyThread = new Thread(My_start);
MyThread.SetApartmentState(ApartmentState.STA);
MyThread.Start();
}
public void StartBrowser()
{
MyInterface = new MyWindow();
MyInterface.Show();
}
public string SaveNow()
{
return MyInterface.dCopyMyFile();
}
}
public partial class MyWindow : Form
{
public DelegateCopyToFile dCopyMyFile;
public MyWindow()
{
…
dCopyMyFile = new DelegateCopyToFile(this.SaveFile2);
}
public string SaveFile2()
{
…
}
}
}
Everything works fine till SaveFile2. There the webbrowswer throws an exception:
“COM object that has been separated from its underlying RCW cannot be used”
I’m running .net 2.0 and the only fix I can find is
http://support.microsoft.com/kb/818612/
When I install it says, “You already have this installed”.
There are some issues with Marshall but I’m not using that.
Any leads would be helpful.
Thanks
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
Hi
How to make phone call with or without c# with small amount of code????
thx
nemanja
|
|
|
|
|
I need something like an enumeration of classes.
<br />
class Garage{<br />
<br />
public static Car Ford = new Car (.....);<br />
public static Car Chevy = new Car (.....);<br />
public static Car Subaru = new Car (.....);<br />
public static Car Mazda = new Car (.....);<br />
<br />
}<br />
then do something like
<br />
foreach(Car x in Garage){<br />
...<br />
...<br />
}<br />
<br />
Funny thing: By force of habit, I hit F6 after I typed this..;P
|
|
|
|
|
Use a collection.
public static Car = nll;
ArrayList list = new ArrayList();
Ford = new Car (.....);
list.Add(Ford);
foreach(Car c in Garage)
.......
Mike
If you keep doing what you've been doing you'll keep getting what you've been getting!
|
|
|
|
|
Mike Hankey wrote: ArrayList list = new ArrayList();
But only in C# 1.1, otherwise, use generic collections.
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 )
|
|
|
|
|
Yes..Thank You
I'm still converting from VS2002 to VS2005 , its taking awhile?
Mike
If you keep doing what you've been doing you'll keep getting what you've been getting!
|
|
|
|
|
dino2094 wrote: public static Car Ford = new Car (.....);
public static Car Chevy = new Car (.....);
public static Car Subaru = new Car (.....);
public static Car Mazda = new Car (.....);
Wouldn't it make more sense to have a collection of car types, as derived classes ? Can't you ever have more than one Mazda in your garage ?
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: Can't you ever have more than one Mazda in your garage ?
Or even more than one Mazda in all garages (note, he's declared them as static )
|
|
|
|
|
Hi people
I am am making a small app where i want to upload report from ado.net access database to internet;
How to do that??
It isn't matter if it is mysql or ...
nemanja
|
|
|
|
|
conemajstor wrote: i want to upload report from ado.net access database to internet;
What do you mean, "to the internet"? To a web application or web service on the internet?
|
|
|
|
|
Hi All,
I want to add grouping function to DataGrid(vs 2003) control, like outlook. but I need a row (cover columns) to show the group title. By the way, my datagrid is bound to Arraylist!
Does anyone have ideas about how to draw a full row in DataGrid control (not DataGridView)? This row will cover all the visible columns. and there should no grid line, the content need to cover all the columns.
Thanks a lot for any suggestion!!
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
Lets say I have
enum OutputFormat {
HEX,
BINARY
DECIMAL
}
class Foo{
...
...
public void print(OutputFormat x){
....
....
}
foo y = ....;
y.print(OutputFormat.HEX);
But I'd like to ties the enum to the class so that the call would look like
y.print(Foo.OutputFormat.HEX); instead of the y.print(OutputFormat.HEX);
Any ideas>
Thanks
|
|
|
|
|
class Foo{
public enum OutputFormat {
HEX,
BINARY
DECIMAL
}
...
}
You can also use private to make the enum only useful within the class.
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 )
|
|
|
|
|
I'm a retard. I could swear that I retried that and got a compiling error!
It works now.
Thank you very much, I can stop banging my head on the desk.
|
|
|
|