|
Programm3r wrote: Would you say that the Crc method look good after my C# interpretation?
I am not sure that it is correct, as the result (which should fit in a 16 bit number) overflowed. I have modified it slighty, best would be to test the output with the output of the native function.
static unsafe ushort crc16(char* pBuf, int Len, ushort InitialCrc)
{
ushort crc = InitialCrc;
for (int i = 0; i < Len; i++)
{
crc = (ushort)((crc >> 8) | (crc << 8));
crc = (ushort)(crc ^ *pBuf);
crc = (ushort)(crc ^ ((crc & 0xff) >> 4));
crc = (ushort)(crc ^ (crc << 12));
crc = (ushort)(crc ^ ((crc & 0xff) << 5));
pBuf++;
}
return crc;
}
|
|
|
|
|
leppie, thank you very much. It looks perfect according to my previous results done in C++ ... five from me :
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
You have changed the type from ushort to uint, I'm not sure that works properly.
Do you really want to use unsafe code and pointers? Why not just use a string?
The InitialCrc value isn't used in the method at all, so you should remove it.
ushort crc16(string buffer) {
ushort crc = 0;
foreach (char c in buffer) {
crc = (crc >> 8) | (crc << 8);
crc ^= (ushort)c;
crc ^= (crc & 0xff) >> 4;
crc ^= crc << 12;
crc ^= (crc & 0xff) << 5;
}
return crc;
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,
kindly let me know that, how may I correct the following problem?
* this connection string works good :
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\BT.XLS;Extended Properties=""Excel 8.0;HDR=YES;""";
* but this does not work by using textBox1.text :
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ textBox1.Text +";Extended Properties=""Excel 8.0;HDR=YES;""";
error is : "; expected"
Thank you in advance
(Riaz)
|
|
|
|
|
Did you try debugging to see what is the actual value of ConnectionString after assignment?
|
|
|
|
|
He can't debug it as it doesn't compile.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Oh, I see. I thought he was getting error when he was trying to open excel workbook.
|
|
|
|
|
|
You have forgotten the @ before the second literal string.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
kindly fix the problem of my mentioned connection string that where should be place @
|
|
|
|
|
You don't understand your own code?
You have a @ delimited string which you have split into two strings, but you have forgitten to put the @ delimiter before the second string.
Example:
string s = @"A ""string"" with some ""quotes"".";
Split into two strings:
string s = @"A ""string"" with " + @"some ""quotes"".";
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
This should work:
To many qoutes according to me....
string ConnectionString = String.Concat(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=", textBox1.Text ,";Extended Properties=Excel 8.0;HDR=YES;");
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
|
You can build your string like this:
string ConnectionString = String.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;""", textBox1.Text)
By the way, give your controls more meaningful names.
|
|
|
|
|
Use it this way. @ comes before any string segment
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ textBox1.Text + @";Extended Properties=""Excel 8.0;HDR=YES;""";
|
|
|
|
|
Just try this:
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source='"+ textBox1.Text +"';Extended Properties=""Excel 8.0;HDR=YES;""";
Be a good professional who shares programming secrets with others.
|
|
|
|
|
i want to make the fix sized text in text box(e.g 10 characters).
it means i made a textbox and also want that user can't enter the characters upto 10 characters..
user is bound at 10 character.
--------------------------------------------------------------------------------
maifs
maifs
|
|
|
|
|
Set MaxLength property of textbox.
-Dave.
------------------------------------
http://www.componentone.com
------------------------------------
|
|
|
|
|
|
TextBox1.MaxLength =10;
hghghgh
|
|
|
|
|
How do I write a console application that imoplements a recursive function
that calculates the approximate infinite sum(of time) of zeno's paradox depending on the number of attempts of Archelles to overtake the tortoise.
Thanks
|
|
|
|
|
What is it that you have problems with?
Creating a console application project?
Implementing a recursive function?
Understanding the homework assignment?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Its all about implementing a recursive function.
|
|
|
|
|
You're going to need a very large stack to calculate an infinite sum. I suggest you use a Turing machine; it can do anything!
|
|
|
|