I have a problem!!

I am trying to convert pascal code to VB and am stuck.

Pascal:

TYPE
Elements = SET of 1..255;
Xpath = ARRAY[0..50] of BYTE;

VAR
Path0,Path1,Path2:Elements;
Path:Xpath;

So, Elements is defined as a base set of numbers 1 through to 255 (inclusive). Path0, Path1 and Path2 are defined as working variables within the program which can hold any value from the range defined in Elements.

In the code itself:

Path0:=[];
FOR i:=1 TO Num DO
BEGIN
Valve:=Config.Ident[Order[i].Rv];
WRITELN(' ',Valve);
Path:=Pathmatrix[Order[i].Rv];
Path1:=[];Path2:=[];
FOR z:=1 TO Path[0] DO
Path1:=Path1+[Path[z]];
Path2:=Path1-Path0;
Path0:=Path0+Path2;
Design(Order[i].Rv)
END;
Printout(Order[i].Rv);
END

Path0 is initialised (assigned an empty set) Path0:=[]

Path1:=Path1+[Path[z]]; Combines set Path1 and an element of array Path

Path2:=Path1-Path0; removes set path0 from set path1
Path0:=Path0+Path2; combines sets path0 and path2

if a specific value appears in more than one set, then the other duplicate value is ignored. That is, only one instance of the value is copied to the new set.

MY QUESTION IS,

HOW IS THIS REPLICATED IN VB. I am converting to excel VB. I am naively hoping the solution is as simple as calling a subroutine...

Thanks,
Enee

It's not. There are things happening in that code that VB can't replicate the same way pascal does it's thing. If you give me a stronger idea of what the program is doing (the entire program) then I might be able to get a feel for how to restructure it for VB, but with the code provided above, requires a stronger understanding of pascal than I know.... you might consider looking into user defined types, and arrays..... maybe it's creating an array of user defined types, and then deleting them.... I dunno.

var Counter, NextNumber : Integer;
begin
 for Counter := 1 to 6 do
 begin
 NextNumber := Random(50) + 1;
 WriteLn(NextNumber);
 end;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.