Solved

VB6 to Delphi

Posted on 2011-02-16
5
794 Views
Last Modified: 2013-11-25
How do i convert the following code to a Delphi format ?

Check = Check Mod (CLng(2) ^ CLng(16))
 
  MSB = Check \ (2 ^ 8)
  MSB = MSB Or 2 ^ 7
 
  LSB = Check Mod (2 ^ 8)
  LSB = LSB Or 2 ^ 7
 
  CalcCheck = Chr$MSB) & Chr$(LSB)

Thanks.
0
Comment
Question by:DavidYori
5 Comments
 
LVL 24

Accepted Solution

by:
jimyX earned 500 total points
ID: 34907098
I am not a VB coder but here I try;
uses Math;
procedure TForm1.Button1Click(Sender: TObject);
var
  check, MSB,LSB :integer;
  CalcCheck : string;
begin
  Check := Check mod round(math.Power(2,16));
  MSB := Check div round(math.Power(2,8));
  MSB := MSB or round(math.Power(2,7));
  LSB := Check mod round(math.Power(2,8));
  LSB := LSB or round(math.Power(2,7));
  CalcCheck := Chr(MSB) + Chr(LSB);
end;

Open in new window

0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 34907240
you could also use shl
var
   check, Msb, LSB: integer;
 
begin
  Check := Check mod (2 shl 16);
  MSB := Check div (2 shl 8);
  MSB := MSB or (2 shl 7);
  LSB := Check mod (2 shl 8);
  LSB := LSB or (2 shl 7);
  CalcCheck := Chr(Msb) + Chr(Lsb);
end;
 
0
 
LVL 32

Expert Comment

by:ewangoya
ID: 34908368

Geert
You are trying to be sleek, LOL
Nice and fast code
0
 

Author Closing Comment

by:DavidYori
ID: 34909886
thanks, works a treat
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 34910211
nope it should have 1 shl 16
... my bad :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now