|
Thanks
I will try it out at home and get back to you tomorrow.
You sure the loop in the first reply will work 100%? So I will be left with (36-4) elements?
B
|
|
|
|
|
Why not just use a string that contains all available characters?
const string chars = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
---
b { font-weight: normal; }
|
|
|
|
|
Because there are 2 properties that can be set to either false, or true. So the user can choose if there is just letters, numbers or both. Then it generates the string/array like you mentioned, that is, if he chose numbers and letter.
Must I then still do it this way as you mentioned??
|
|
|
|
|
Then put the letters in one string and numbers in another, and concatenate these according to what the user has chosen.
string chars = string.Empty;<br />
if (m_bIncludeLetters) chars += letters;<br />
if (m_bIncludeNumbers) chars += numbers;
---
b { font-weight: normal; }
|
|
|
|
|
Ok it sounds good enough, but I will still need to loop through it to search for characters not allowed and to remove them. Once I have removed these characters, then from what is left will I create a unique id of about 9 characaters in length.
private string m_sExcludeChars = "IO01";
If the string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
How do I loop through it and remove the characaters that I have defined in m_sExcludeChars? So the final string should look like this after the 4 characters have been removed:
"ABCDEFGHJKLMNPQRSTUVWXYZ23456789"
O yes, if I declare a char array like:
private char[] chars;
How do I append characters to it? I want a similar result to:
private char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".ToCharArray();
I hope this makes sense.
Regards,
Brendan
|
|
|
|
|
Can't you just remove the unwanted characters from the original string constants?
Otherwise they can be removed with some Replace calls, or more efficiently with a regular expression:
chars = RegEx.Replace(chars, "[IO01]", "");
Do you really need a char array? You can get char values from a string in the same way as from a char array:
char myChar = chars[index];
ma se wrote:
How do I append characters to it? I want a similar result to:
private char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".ToCharArray();
What's wrong with that code?
---
b { font-weight: normal; }
|
|
|
|
|
After an installation for a single user all went well, but it I try the same installation for all users the shortcut on users desktop points not to my application (.exe) but starts the .msi again.
If I start my app (.exe) in the users application folder directly all works fine.
Do I have to install additional folders for a All Users desktop and all users program folder ?
Thanks
Ariadne
-- modified at 10:16 Thursday 6th October, 2005
|
|
|
|
|
I rewrote the whole setup-project: Now it works... It seems an internal error.
Then there is probably a minor bug: If I install a project as all users in the Software-install folder the icon is a yellow folder icon. If I install a project as single user the in the setup project selected icon appears.
Ariadne
|
|
|
|
|
Im working with Sockets in C#, and i have everything working with events and some threads, i am accepting multiple connections i just would like to know how can i detect if a client or a server has closed it's socket. Is there an event or is there a thrown exception is there something i can do to detect this when it happens?
Any help is appreciated.
|
|
|
|
|
hi..
i hav created setup of my desktop application using dot net setup project....i want when installation completes it automatically pop up a readme file ..how can ido this..
thanks
|
|
|
|
|
shashank veerkar wrote:
i want when installation completes it automatically pop up a readme file
in the VS-setup project go to the user interface and add in the End-Section a new dialog form: Readme (or something like that, I use a german version of VS there the name of this dialog is "Infodatei")
Hope this helps
Ariadne
|
|
|
|
|
hi..
im developing a fax service to send fax automatically from a system..for this i need to find how many Fax Machines are attached to the system..and how to get list of them..so please help me to solve this problem...
thanks ..
|
|
|
|
|
Why won't the Form see this method?
///////////////////////////////////////////
//Here's a snippet of my Complex2.cs code (seperate Sol'n file)
private Pen [] activePen;
private int _penIndex = -1;
public Complex2()
{
Pen[] activePen = new Pen[] { new Pen( Color.Blue, 2 ), new Pen( Color.Green, 2 ), new Pen(Color.Red, 2) };
activePen[0].StartCap = System.Drawing.Drawing2D.LineCap.Triangle;
// TODO: Add constructor logic here
real = 0;
imag = 0;
}
public Complex2(double _re, double _im)
{
real = _re;
imag = _im;
}
public Pen GetNextPen()
{
_penIndex = (_penIndex + 1) % 3;
activePen[_penIndex].StartCap = System.Drawing.Drawing2D.LineCap.Triangle;
return activePen[_penIndex];
}
//////////////////////////////////////////////
//Here's some relevant code form Form1.cs
protected Complex2 cmplxValue1 = new Complex2(0,0); //these get values changed from TestBoxes...
protected Complex2 cmplxValue2 = new Complex2(0,0);
void DrawComplexNumber1(Graphics g)
{
Pen p = GetNextPen();
c_xy.SetOrigin(xIndent + graphRect.Width/2, yIndent + graphRect.Y/2);
cmplxValue1.Real = Convert.ToDouble(textComplex_1Real.Text);
cmplxValue1.Imaginary = Convert.ToDouble(textComplex_1Imaginary.Text);
g.DrawLine(GetNextPen(), 250, 250, (float)(250 + (xIndent * cmplxValue1.Real)), (float)(250 - (yIndent * cmplxValue1.Imaginary)));
}
ERROR
CForm1.cs(335): The name 'GetNextPen' does not exist in the class or namespace 'ComplexTest2.Form1'
Even if I try this:
g.DrawLine(cmplxValue1.GetNextPen()....) the instantiated object doesn't "see" the method... please help thanks a lot....
|
|
|
|
|
You wrote Anonymous wrote:
Pen p = GetNextPen(); this will generate
The name 'GetNextPen' does not exist in the class or namespace 'ComplexTest2.Form1' error because the compiler will think GetNextPen() member of Form and this not true
because it is a member of complex2 and you didn't call it from an object of this class
Anonymous wrote:
Even if I try this:
g.DrawLine(cmplxValue1.GetNextPen()....) the instantiated object doesn't "see" the method... please help thanks a lot....
are you replaced all places you call this function or gust this line? you need to replace all the places like
Pen p = GetNextPen(); too
MCAD
-- modified at 1:01 Thursday 6th October, 2005
|
|
|
|
|
hi there!
can i know what designer class should i inherit to use it for winforms?
i used the parentcontroldesigner class, but it seems it's not applicable..
or a winform doesn't support designer? if ever, what should i do to make a designer verb for winforms?
tnx in advance!
|
|
|
|
|
You may want to take a look at the code for #Develop. If I recall correctly, they've got a WinForms designer in there. Might be worth taking a look at.
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..."
-Jörgen Sigvardsson
|
|
|
|
|
Why if XmlReader has an EOF property, the BinaryReader doesn't have it?
I don't like this, you can read why in my blog:
The EOF Issue[^]
How do you solve this issue?
Eduardo Diaz
site | english blog | spanish blog
|
|
|
|
|
Use the ReadBytes method.
---
b { font-weight: normal; }
|
|
|
|
|
Yes, we can use ReadBytes, then why bother to use BinaryReader!?
I like to BinaryReadar because you read primitive types.
using ReadBytes you have to write code like this:
byte[] data = f.ReadBytes(sizeof(double));
double value = BitConverter.ToDouble(data, 0);
The problem is that accroding to documentation:
==== Microsoft Documentation ====
Return Value
A byte array containing data read from the underlying stream. This might be
less than the number of bytes requested if the end of the stream is reached.
======
What happen when EOF is reached? data is null?
Also this could generate an exception to be thrown when I call BitConverter.ToDouble().
BinaryReader is bad designed.
Eduardo Diaz
site | english blog | spanish blog
|
|
|
|
|
ediazc wrote:
What happen when EOF is reached? data is null?
No. You simply get an array that contains less bytes that you requested.
The way to detect end of stream is to examine the length of the array. If the length is shorter than the number of bytes requested, you have reached the end of the stream. The array will contain the last remaining bytes of the stream. If you already read all data up to the end, the length of the array will be zero.
You have to check the length of the array before you try to convert the bytes to a double. If there aren't bytes enough for a double, you have reached the end of the stream.
ediazc wrote:
BinaryReader is bad designed.
I don't think so. Perhaps it's not designed the way you are used to, or maybe not designed the way you try to use it. I believe it's rather well designed for it's purpose, though.
---
b { font-weight: normal; }
|
|
|
|
|
From your blog, your first snippet of code does work, with a few modifications.
void Open()
{
FileStream stream = File.Open(@"C:\myfile.txt", FileMode.Open);
byte b;
while ((b = (byte)stream.ReadByte()) != 255)
{
Console.WriteLine(b.ToString());
}
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Then it can't be used to read a file thas has the byte value 255 in it, as that also will be interpreted as end of file.
---
b { font-weight: normal; }
|
|
|
|
|
Oops. b must have been declared int and I shouldn't have casted ReadByte . This will work
void Open()
{
FileStream stream = File.Open(@"C:\myfile.txt", FileMode.Open);
int x;
while ((x = stream.ReadByte()) != -1)
{
byte b = (byte)x;
Console.WriteLine(b.ToString());
}
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
|
That particular code is not mine, is taken from microsoft documentation.
The error is from the documenter, who obviusly doesn't know how to read a stream .
Eduardo Diaz
site | english blog | spanish blog
|
|
|
|