|
Brute force and ingnorance approach: Convert to a string, use substring to get the right hand end.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
Sounds easy enough but the problem is that I have no idea how long the string will be. It could be 20 digits, 30 digits, 15 digits or 12 digits.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
So? Why would you care?
number.ToString() doesn't care how long it is.
string.Length tells you how long the other one is.
You know how many digits you want to keep...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
Aye, I got it. Below is what I have done.
FinalHash = homingTotal + OverFlow + ContraHash;
string hashfinal = Convert.ToString(FinalHash);
int length = hashfinal.Length;
int remove = length - 12;
outhash = hashfinal.Substring(remove, 12);
finalhashtotal = Convert.ToInt64(outhash);
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
How about
long lDigits = lCalulatedVal % 1000000000000;
this should do the trick.
Greetings
Covean
|
|
|
|
|
Hello
Could you please help me to make a convertion from a structure to byte array?
Is there any function to do that?
I would appreciate if you could give a short sample of code
Thanks
|
|
|
|
|
|
I want to generate a Unique ID as this. Unique ID Should Look like this "CID-00001,CID-00002,CID-00003.....".
I need a class to generate this. First i need to check the database for the previous ID.
If there is No Data it should generate the ID as "CID-00001" else it get the last ID and increment it by one and store it to the database.
I need the C# code for this.
Thank you.
|
|
|
|
|
Have you tried anything?
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Yes, posted a question here in the hope of somebody giving him the code
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
|
Well it has the advantage of honesty!
Not enough to just give you the code, but at least it's honest.
First: Decide what database system you will use. What have you got to play with?
Second: Create a table in the database, create a field in the table.
Third: Write code:
Third.First: Connect to database
Third.Second: Read from database, identify highest existing entry
Third.Third: Increment enty to create new one.
Third.Fourth: Add to database, check for error.
Third.Fifth: If error, repeat from Third.Second.
Fourth: Use new entry as number.
There are other ways to do it, but that is the basic idea.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
Try searching for GUID on msdn. You might get what you want.
|
|
|
|
|
Abhinav S wrote: You might get what you want.
But I doubt it when he doesn't want guids. The OP says Should Look like this "CID-00001,CID-00002,CID-00003.....", which are not GUIDS (but are dead easy to generate anyway)
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Then I suppose its just a lot of homework .
|
|
|
|
|
hi all,
i m working in a desktop application in which i added reference of MS WORD DLL and MS EXCEL DLL, and all reporting is Done in Word File and Excel File, project is working fine but whenever we installed program in any other system which contain MS OFFICE of other version an error generated,
Example: -
if i include reference of ms office 97, word ddl than i open exiting file as
WordDoc = new Word.Document();
WordApp = new Word.ApplicationClass();
WordDoc=WordApp.Documents.Open(ref filename, ref missing, ref readOnly,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
WordApp.Visible = true;
if we include reference of ms word XP dll than we open file as
WordDoc=WordApp.Documents.Open(ref filename, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing);
WordApp.Visible = true;
simiraly MS OFFICE 2003
includes some more parameter for OPEN method
my problem is that how can we include a Reference which work same for all version, because for every version of OFFICE we cannot make seperate code
thanks
in VB 6.0 we hav to add or change only reference and no need to change in code, but in C# .net i have to change the code as well as Reference of Office DLL.
thanks pls help me
|
|
|
|
|
I think you can make use of late binding here. Or have something like:
if(Office 2003){
}
else if (Office 2007){
}
else{
}
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
can u show an example which will be same for all version of MS OFFICE, just simply opening a file.
|
|
|
|
|
The InterOp-DLL's for Office are version-specific, and you'll need the same version on the desktop. You could use a plugin-architecture (the strategy pattern) to decouple the logic from your application.
ishika_kukki wrote: in VB 6.0 we hav to add or change only reference and no need to change in code, but in C# .net i have to change the code as well as Reference of Office DLL.
Can you show an example?
I are Troll
|
|
|
|
|
Hi,
I'm trying to save the context that i have in my textBox (Multi Line) to a text file,
But to keep the lines order.
i know how to do it with richTextBox-
foreach (string line in richTextBox.Lines)<br />
{<br />
textToSave.WriteLine(line);<br />
<br />
}
But i have to user textBox only...
Someone has a idea?
|
|
|
|
|
You can make use of File.WriteAllLines method to do this.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
hi
why you write the text line by line?
using(StreamWriter sw = new StreamWriter(filename))
{
sw.Write(textbox.Text);
}
regards
|
|
|
|
|
Thanks,
It's working great...
|
|
|
|
|
Hi,
I'm after some suggestions on best practice to resolve an issue of loading large data combobox's (WPF).
I have two combo's Country & Airport. Country combo is to filter Airport combo (with just Airports in that Country) simple...
There are approx 260 Countries and 10,000+ airports worldwide
Using MVVM
public viewmodelFlights()
{
CountryList = new List<CountryModel>(wcfService.GetCountries());
AirportList = new List<AirportModel>(wcfService.GetAirports());
icCountryView = CollectionViewSource.GetDefaultView(CountryList );
icCountryView.CurrentChanged += new EventHandler(icCountryView_CurrentChanged);
icCountryView.MoveCurrentToPosition(-1);
icAirportView = CollectionViewSource.GetDefaultView(AirportList );
icAirportView.CurrentChanged += new EventHandler(icAirportView_CurrentChanged);
icAirportView.MoveCurrentToPosition(-1);
} just so you get the vm idea
I'm trying to get this initial loading quicker. Is there anyway to only load the airports once the Country has been selected?
I have a bigger problem with a hospital list which has 1,000,000+ records!!
|
|
|
|