|
Your probaby right.
However, I was trying to stick with the standard string formatting options.
In the end as I noted above I did the following:
I ended up using the format string "000000%" which multiplies by one hundred thus
given me the assumed decimal place. Then in my ProcessNumber method I remove the "%" if it exists.
The "%" will only exist if I am using the assumed decimal approach and I can still
use standard formatting for all clients.
Problem solved.
|
|
|
|
|
Just pray that the system doesn't use currencies that has no "cent", ie Won, Dong, Yen.
|
|
|
|
|
Yeah, I took that into consideration, the amounts are always even dollar amounts and always US currency.
thanks
|
|
|
|
|
I have a TreeView on my form as well as a ListBox. I have an Artist, Album and Song class which each extend the TreeNode class. The ListBox holds a list of songs which will be copied to a removable device. Now what I want to do is be able to drag an artist node, album node or a song node onto the list box and have all the songs under the dropped node show up in the ListBox. I know I need to use the DragDrop, Drag Enter and/or DragLeave events but I don't know how.
|
|
|
|
|
|
|
Ugh, well, im trying to write an app that will take a screenshoot and then proceed to send an email to our support ticketing software, all goes well, except for the fact that my attachment never gets through. I can send attachments and all fine from my client, but when attaching via code, it seems to just disappear. any ideas or known workarounds?
more or less the code:
<br />
MailMessage Mail = new MailMessage("fake@fake.com", "fake@fake.com");<br />
Mail.Subject = "testing ticket system";<br />
Mail.Body = "lalala wtf....";<br />
<br />
Attachment File = new Attachment(@"C:\Screenshot.jpg");<br />
Mail.Attachments.Add(File);<br />
<br />
SmtpClient SMTP = new SmtpClient();<br />
SMTP.Host = "somefakeserver.com";<br />
SMTP.Port = "25";<br />
<br />
SMTP.Send(Mail);<br />
message comes through, but no attachment.
|
|
|
|
|
I'm trying desperately to find a reliable and repeatable way to identify a given machine. One of the things I've tried is using the Win32_ComputerSystemProduct class. I wanted to use the UUID property, but on home-built systems (and indeed, even on some retail systems), this value is either all zeros or all F's.
How is this property value set? I did a search in the registry, but the search resulted in nothing being returned. Can this only set during the install of Windows?
"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 hope this helps
although u probably gone there
[^]
UUID
Data type: string
Access type: Read-only
Universally unique identifier (UUID) for this product. A UUID is a 128-bit identifier that is guaranteed to be different from other generated UUIDs. If a UUID is not available, a UUID of all zeros is used.
Have Fun
Never forget it
|
|
|
|
|
Look at UUID MappingStrings qualifier, it's value is:
SMBIOS|Type 1|UUID
|
|
|
|
|
Hi John,
I just discovered Win32_BaseBoard.SerialNumber, maybe that suits your needs. Please let me know
what your conclusions will be, I have a similar need.
BTW: would Win32_ComputerSystemProduct.UUID remain constant when reinstalling (or upgrading) Windows?
|
|
|
|
|
Luc Pattyn wrote: I just discovered Win32_BaseBoard.SerialNumber, maybe that suits your needs. Please let me know
what your conclusions will be, I have a similar need.
Here are some things I've discovered in the last few weeks...
1) MAC addresses should never be used to identify a machine. Why? Because a machine could have two adapters (wireless and wired - like most modern laptops). If BOTH/ALL NICs are disabled, you can't get ANY mac address.
2) The BaseBoard serial number is almost always empty after the user updates the bios the first time. This is especially true on home-made desktop systems. None of my home systems (all home-built) have a baseboard serial number because all of them have had their BIOS's updated. My laptop has also had a bios update (twice in fact), yet it retains its original serial number.
3) I'd expect the Win32_ComputerSystemProduct.UUID to be the same after a windows install, but as previously pointed out, a home-built machine will probably not have a meaningful UUID. On the other hand, my Acer laptop has one, even without the original OS installed (it came with Vista, and I installed XP).
I figured setting a meaningless UUID from within my app would result in a UUID that isn't all 0's or all F's. Documentation is pretty scarce about this topic.
"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
|
|
|
|
|
Hi,
I always use the symbol '@' as a pointer to the first byte of a buffer, but what it means in C# now? Is it a reference or something?
What is the difference between string delimit = @"\"; and string delimit = "\";
Thanks,
Dirso
|
|
|
|
|
Dirso wrote: What is the difference between string delimit = @"\"; and string delimit = "\";
in C# the first compiles, the second does not, due to an invalid escape sequence.
|
|
|
|
|
In C# it means what it's always meant :P
In the case your showing it means 'literal string' i.e.
one which isn't processed and so theres no need to escape anything other than double quotes.
"////machinename//" == @"//machinename/"
It does also have another use which is to allow you to use reserved words as identifiers i.e.
public class @readonly {}
But that is not a good idea reserved words are reserved for a reason
|
|
|
|
|
originSH wrote: "////machinename//" == @"//machinename/"
I don't think so.
|
|
|
|
|
oh nuts ... yeah it should be:
"\\\\machinename\\" == @"\\machinename\"
Good spot
|
|
|
|
|
|
Thank you both! I had needed to use @ in Delphi so much that I completly forgot it's (not too good) use in C. And sorry for the horrible example in my question, of course "\" wouldn't compile, it was just a dummy question
Thank you so much,
Dirso
|
|
|
|
|
|
Ive got a form that the user can enter information on, when clicking the "SAVE" button the general proccess is the following...
private void SaveData()
{
if(dataIsValid())
{
}
}
lets say the form has a TextBox and a ComboBox
the dataIsValid() method will look something like this
private bool dataIsValid()
{
if (textBox1.Text = "")
{
MessageBox.Show("Please Enter A Name");
textBox1.Focus();
return false;
}
else if (comboBox1.SelectedValue == null)
{
MessageBox.Show("Please Select An Age Group");
comboBox1.Focus();
return false;
}
return true;
}
The idea is to one by one check that the fields have data... But now lets add 3 maskedTextBoxes with mask "##:##" for a time span value. Now the data doesn't just have to be there, but valid as well.
the solution i came up with looks dodgy and can be a nightmare to maintain... its as follows
private bool dataIsValid()
{
if (textBox1.Text = "")
{
MessageBox.Show("Please Enter A Name");
textBox1.Focus();
return false;
}
else if (comboBox1.SelectedValue == null)
{
MessageBox.Show("Please Select An Age Group");
comboBox1.Focus();
return false;
}
try
{
TimeSpan.Parse(maskedTextBox1.Text);
try
{
TimeSpan.Parse(maskedTextBox2.Text);
try
{
TimeSpan.Parse(maskedTextBox3.Text);
}
catch
{
MessageBox.Show("Please Enter A Duration");
maskedTextBox3.Focus();
return false;
}
}
catch
{
MessageBox.Show("Please Enter A Duration");
maskedTextBox2.Focus();
return false;
}
}
catch
{
MessageBox.Show("Please Enter A Duration");
maskedTextBox1.Focus();
return false;
}
return true;
}
Does anyone have any better ideas cuz im all out?
Im sure there has to be a better way of doing this...
Thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
u can use the Mask Property that validates for u
and also
use the maskedTextBox1_MaskInputRejected Event that this Param
(object sender, MaskInputRejectedEventArgs e)
and :
e.Position
e.RejectionHint
Have Fun
Never forget it
|
|
|
|
|
Try writing one routine that will validate a control of a given type, then call that routine with each control of that type. It's less code, lower complexity, and only one place to update the validation algorithm if it needs to change.
|
|
|
|
|
I would recommend wiring into all the controls Validating events, then you can just call the forms ValidateChildren method to validate everything. I'd also recommend using an Error Provider, which can display an icon and error tooltip beside each invalid control.
If you'd prefer to keep your current structure for validation and just clean it up a bit, you could use the TimeSpan.TryParse instead of TimeSpan.Parse, like so:
<br />
TimeSpan timeSpan;<br />
if(!TimeSpan.TryParse(maskedTextBox1.Text, out timeSpan)){<br />
}<br />
|
|
|
|
|
thanx for the reply...
i wasnt aware of the TryParse() method... thank you
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|