VB.NET class in Delphi.NET

Posted on 2006-11-25
Last Modified: 2006-11-30

I have a VB.NET class which I want to use in my web application.
Can this be done or do I have to rewrite the class in Delphi.NET?

Question by:nathc100
  • 3
  • 3
LVL 96

Expert Comment

by:Bob Learned
ID: 18018716
You should be able to create a VB.NET DLL that you could reference in the Delphi application.


Author Comment

ID: 18023397
Hmmm OK I'm thinking I'll just convert to Delphi the VB(it's actually VB not VB.NET) class isn't too long or complicated.
Do you have any experience with Delphi.NET and writing classes?
LVL 96

Expert Comment

by:Bob Learned
ID: 18026880
No, unfortunately I haven't had the time nor the inclination to learn.  It might be possible to convert the VB class to VB.NET, build a DLL, and then use Reflector + File Disassembler to get Delphi.NET code that would give you a place to start.

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.


Author Comment

ID: 18044028
OK Bob,

Here's a curly one if you can give me the answer I'll give you the points.
How do I convert the VB statement "Redim Preserve" into Delphi syntax?


Public Sub SetColumns(inNum)
  Dim i
  If inNum > 0 Then
    ReDim Preserve mWidths(inNum - 1)
    For i = (mColumns - 1) To (inNum - 1)
      If i >= 0 Then mWidths(i) = 1
    mColumns = inNum
  End If
End Sub
LVL 96

Accepted Solution

Bob Learned earned 250 total points
ID: 18044515
Here's my best guess (using Reflector):

procedure Form1.SetColumns(inNum: TObject);
      obj1: TObject;
      obj4: TObject;
      if (Operators.ConditionalCompareObjectGreater(inNum, 0, false)) then
            self.mWidths := (Utils.CopyArray((self.mWidths as Array), New(array[(Conversions.ToInteger(Operators.SubtractObject(inNum, 1)) + 1)] of Integer)) as Integer[]);
            if (ForLoopControl.ForLoopInitObj(obj1, (self.mColumns - 1), Operators.SubtractObject(inNum, 1), 1, @(obj4), @(obj1))) then
                        if (Operators.ConditionalCompareObjectGreaterEqual(obj1, 0, false)) then
                              self.mWidths[Conversions.ToInteger(obj1)] := 1
                        until not ForLoopControl.ForNextCheckObj(obj1, obj4, @(obj1));
                  self.mColumns := Conversions.ToInteger(inNum)


Author Comment

ID: 18044633
Hey Bob,

I actually found a very easy way to do it just using SetLength(mWidths,inNum-1) as my array is dynamic.
But I'm true to my word so you get the points. Thanks for your help.

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

9 Experts available now in Live!

Get 1:1 Help Now