Solved

How to convert the code form vba macro to c#.net

Posted on 2014-09-12
4
182 Views
Last Modified: 2014-09-18
Hi,

could you please help me out how to convert the function from vba macro to c# code .i am not able to convert to c# code.Please help me out.
i mention in the below.

Public Sub Clear_ER_And_Impact_Info(Optional Number_of_Equations As Integer = 0)
  ReDim Face_ImpSpeed(1 To Number_BdyFace)
  ReDim BdyFace_Angle(1 To Number_BdyFace)
  ReDim Face_MassRate(1 To Number_BdyFace)
  If Number_of_Equa = 0 Then Number_of_Equa = UBound(Face_Erosion, 1)
  ReDim Face_Erosion(1 To Number_of_Equa, 1 To Number_BdyFace)
End Sub

Thank you in advance.
0
Comment
Question by:mannevenu26
  • 2
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40323315
Instead of using arrays, I would use generics (List<int>), and then you don't need to try to find an equivalent for ReDim in C#.  You can add and remove items, without needing to be concerned with size.
0
 

Author Comment

by:mannevenu26
ID: 40327972
Hi Bob Learned (TheLearnedOne),

Thank you i support your answer.
could you plz give how to change on below vba macro code.Please help me out regarding on this...

Public Sub Clear_ER_And_Impact_Info(Optional Number_of_Equations As Integer = 0)
  ReDim Face_ImpSpeed(1 To Number_BdyFace)
  ReDim BdyFace_Angle(1 To Number_BdyFace)
  ReDim Face_MassRate(1 To Number_BdyFace)
  If Number_of_Equa = 0 Then Number_of_Equa = UBound(Face_Erosion, 1)
  ReDim Face_Erosion(1 To Number_of_Equa, 1 To Number_BdyFace)
End Sub


Thank you in advance.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 40328054
I have know idea what you are really working with, but maybe something like this:

public class ErosionImpact
{
   public List<int> FaceImpactSpeed { get; set; }
   private List<int> BodyFaceAngle { get; set; }
   private List<int> FaceMassRate { get; set; }
   private List<int> FaceErosion { get; set; }

   public void ClearErosionAndImpactInfo()
   {
      FaceImpactSpeed.Clear();
      BodyFaceAngle.Clear();
      FaceMassRate.Clear();
      FaceErosion.Clear();
  }

}

Open in new window

0
 

Author Closing Comment

by:mannevenu26
ID: 40329862
ok
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 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