Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB6 to Delphi

Posted on 2011-02-16
5
Medium Priority
?
850 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 24

Accepted Solution

by:
jimyX earned 2000 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 38

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:Ephraim Wangoya
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 38

Expert Comment

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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

618 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