|
Thanks
I'll play. Hope you get my point about skinning cats. I just sat there and thought. "Right, now which of five ways am I going to approach this"
As ever, any other insights etc....
|
|
|
|
|
i am developing a VB code to generate CRC-CCITT for my data frame
which is
(0x01 0x10 0x01 0x20 0x02 0xF0 0x04 0x02 0x23 0x10 0x63 0x02 0x03 0xFA 0x33 0x04)
so if i send 0x01 0x10 0x01 0x20 0x02 0xF0 0x04 0x02 0x23 0x10 0x63 0x02 0x03 to a crc-ccitt function i should get crc 0xFA 0x33 which i will add to my data and put an end of header then send via comm port
this what have tried but i am not getting 0xFA 0x33 as required by the protocol
'************************************************************************************
'test with this hex string 0110012002F004022310630203 i am suppossed to get crc FA33
' Or testing with 0110012016F004022310590203 should give crc 5F06
' CRC-CCITT Polynomial: 1021h = x16 + x12 + x5 + 1 (LSB first mode)Start value: FFFFh
'******************************************************************************************
Private Sub CommandButton1_Click()
Dim crc As Long
Dim n As String
Dim values(13) As Byte
Dim k As Integer
Dim i As Integer
crc = &HFFFF&
n = text1.Text
k = 0
For i = 1 To Len(n)
values(k) = "&H" & Mid(n, i, 2)
i = i + 1
k = k + 1
Next i
For k = 0 To 12
crc = calc_crc(crc, values(k))
Next k
MsgBox ("Crc " & Hex(crc))
End Sub
Private Function calc_crc(ByVal crc_buff As Long, ByVal inp As Byte) As Long
Dim i As Integer
Dim x16 As Long
Dim values(13) As Byte
For i = 0 To 12
If ((crc_buff And 1) Xor (inp And 1)) = 1 Then
x16 = &H8408&
Else
x16 = 0
End If
crc_buff = crc_buff \ 2
crc_buff = crc_buff Xor x16
inp = inp \ 2
Next i
calc_crc = crc_buff
End Function
please urgent
|
|
|
|
|
In troubles again?
BTW you know, marking a request as 'urgent' will make it fall to the bottom of the stack.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
singende wrote:
Private Sub CommandButton1_Click()
Dim crc As Long
Dim n As String
Dim values(13) As Byte
Dim k As Integer
Dim i As Integer
crc = &HFFFF&
n = text1.Text
k = 0
For i = 1 To Len(n)
values(k) = "&H" & Mid(n, i, 2)
i = i + 1
k = k + 1
Next i
For k = 0 To 12
crc = calc_crc(crc, values(k))
Next k
MsgBox ("Crc " & Hex(crc))
End Sub
That's a bit rubbish. Try with:
Private Sub CommandButton1_Click()
Dim crc As Long
Dim n As Integer
Dim values() As Byte
Dim length As Long
Dim sval As String
sval = text1.Text
length = Len(sval) / 2
ReDim values(length) As Byte
crc = &HFFFF&
For n = 0 To length - 1
values(n) = CLng("&H" & Mid(sval, 1 + n * 2, 2))
Next n
For n = 0 To length - 1
row = n + 1
crc = calc_crc(crc, values(n))
Next n
MsgBox ("Crc " & crc)
End Sub
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Private Carlo,
You have been called Blessed and Schmuck now.
By your own principles, you should not support CRC code whatsoever.
Your MVP status is at stake here.
The Klingon-General
|
|
|
|
|
Luc Pattyn wrote: You have been called Blessed
Klingons don't like it.
Luc Pattyn wrote: and Schmuck
The Klingon warrior will soon kill the offender (you know, honour...)
Luc Pattyn wrote: By your own principles, you should not support CRC code whatsoever
That wasn't really support. My code didn't need any fix. His one, on the other hand...
And, yeah, Mon General, Klingons shouldn't give support, anyway:
VB6 programmers are really, really cursed people, pietas is noblesse oblige with them.- What the fu*k: Klingon warriors obey no General!
Luc Pattyn wrote: Your MVP status is at stake here.
Klingons don't care about whatever MVP status (just kidding Chris, just kidding... )
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Thanks in Advance...
modified 28-Nov-12 4:42am.
|
|
|
|
|
You've been asking this for days. Have you tried stepping through your code to see what's going on ?
Looks to me like some lines have more than two spaces that you need to remove.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
|
Recursion.
But in the manner you'v written it your not going to be able to do it (at least not easy).
Why are you still doing your actions directly in the loop that reads the file?
Go back to one off you previous post where I answered a lot off you questions. And go trough them again.
It is going to be far easier to do all that you want in memory (eg datatable)
Steps:
0) read text file into memory (datatable)
1) go over your datatable and do your actions onto the datatable (delete / insert / alter the rows off the datatable)
2) write the datatable to a new (or overwrite the existing) text file.
|
|
|
|
|
First one Open File and Read the file by line wise.
Then By using Trim ,LTrim ,RTrim ,Left,Right,Mid,Instr,Space,Format Function you can get a real Output.
Best Regard
Anubhava Dimri
mailto: anubhava.prodata@gmail.com
|
|
|
|
|
|
I guess you didn't read his reply, so why did you thank him for it ?
I think you need to use recursion, or just keep count of how many times in you are, and add 2 every time to the number of spaces to remove. Or, just count the number of spaces and cut it down to always the same number. Perhaps with a regex.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
|
That thanks was for the time he spent to look my post...
Im not sure how to use this code to perform recursion...
CODE:
l = name.IndexOf(".")
If name.Contains("Groupe") Then
Grp = True NbOfSpaces = NbOfCar(name, " ") + 2
ElseIf Grp And NbOfCar(name, " ") = NbOfSpaces Then
name = (name.Substring(0, l) & Trim(comp) & name.Substring(l, (name.Length - l) - Nb) & desF.Insert(0, a) & desAF & desA & desAA & ecn & dnf & repDNF & repASM)
sw.WriteLine(name.Remove(0, 2))
Else
Grp = False
End If
Any help on this please...
|
|
|
|
|
Find string and Trim it. then Check if String Start By Grope then NotSAVEIT.
Best Regard
Anubhava dimri
mailto: anubhava.prodata@gmail.com
|
|
|
|
|
Sorry, but I'm gonna have you add you to my personal list to avoid all of your future posts. Your repeated posts about the same question/topic for months on end gets old - esp. when many members have posted suggestions for you to try and you obviously are remiss in implementing them.
Some people just can't be helped - you're one of them.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
name = name.Substring(0,48).TrimStart() + new string(' ', 48-name.Substring(0,48).TrimStart().Length) + name.Substring(49);
It's an ugly way to do it, but that'll strip the leading spaces off the beginning of the lines, while keeping the alignment of later items. The better way to go would be to figure out what the Nom do modele is going to be, trim that, then attach the rest of the line for printing.
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
|
|
|
|
|
I have a project I am using it in my local computer , when I tested my Database in a remote SQL server 2005 computer, it is giving error , while i can connect through SQL server installed in my computer to that SQL server instance and I can work on those Database I can not connect through VB.Net the code writen is as bellow it says to enable the TCP/pipe while both of them are enabled in remote computer.
con = New SqlConnection(" data source =\\servername\instancename; database = Employee;" & "uid=test; pwd=test")
|
|
|
|
|
If you have the servername right, then it's a network issue, or a configuration issue on SQL Server.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
I am just a beginner so I could well be wrong here but I thought that; unless the remote server is on the same domain as the local machine then you are unable to connect to it by using a UNC? (i.e. \\servername) Is this incorrect?
Have you tried connecting to it by using its IP address?
|
|
|
|
|
|
Try Using This
data source=ServerName ;initial catalog=DatabaseName;persist security info=False;user id=DBUserName ;password=DBPassWord;Connection Timeout=600;
Arindam Banerjee
Sr. Software Developer
Rance Computer Pvt Ltd.
Kolkata (India)
|
|
|
|
|
Ensure you have the SQL server configured properly, user/group permissions, and check the *firewall* on the server and client.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|