我已经用C#编写了一个dll以构建形状文件。我从Excel-VBA调用此dll。我想向用户展示dll执行的进度。
我尝试了在这里找到的其他示例,但是这些示例是将信息发送到C#中的其他过程。
这是代码的一部分:
public void CrearMapa(string[] files, string fshp, string pstring, int x, int y, int posS,int posCMP,string[] survey, string[] lineName)
{
char s = '\\';
int bytesTrace, bytes, i,row;
row = 0;
double east, north;
int sp, cmp;
long leap, fsp, lsp, fcdp, lcdp;
//List<string> list = files.OfType<string>().ToList();
int ar = files.Length;
string textFile = fshp + ".txt";
string nfshp = fshp + ".shp";
StreamWriter outF = File.CreateText(textFile);
string lineaC ="SURVEY_CODE"+","+"LINE_NAME"+ ","+"ID" + "," + "SP" + "," + "CDP" + "," + "SEGY_EAST" + "," + "SEGY_NORTH";
outF.WriteLine(lineaC);
var lsf = new LineShapefile(); // it depends on DotSpatial.Data
//FeatureSet lsf = new FeatureSet(FeatureType.Line);
//var proj=ProjectionInfo.FromEpsgCode(crs).ToEsriString();
//lsf.Projection = ProjectionInfo.FromEsriString(proj);
lsf.DataTable.Columns.Add(new DataColumn("ID", typeof(int)));
lsf.DataTable.Columns.Add(new DataColumn("SURVEY_CODE", typeof(string)));
lsf.DataTable.Columns.Add(new DataColumn("LINE_NAME", typeof(string)));
lsf.DataTable.Columns.Add(new DataColumn("FILE_NAME", typeof(string)));
lsf.DataTable.Columns.Add(new DataColumn("FIRST_SP", typeof(long)));
lsf.DataTable.Columns.Add(new DataColumn("LAST_SP", typeof(long)));
lsf.DataTable.Columns.Add(new DataColumn("FIRST_CDP", typeof(long)));
lsf.DataTable.Columns.Add(new DataColumn("LAST_CDP", typeof(long)));
lsf.DataTable.Columns.Add(new DataColumn("CRS", typeof(int)));
lsf.DataTable.Columns.Add(new DataColumn("LENGTH(KM)", typeof(double)));
lsf.DataTable.Columns.Add(new DataColumn("TRACES", typeof(double)));
lsf.DataTable.Columns.Add(new DataColumn("VALIDATED", typeof(double)));
List<Coordinate> listaTemp = new List<Coordinate>();
LineString LS2 = new LineString(listaTemp);
for (i = 0; i < ar; i++)
{
Coordinate coord;
byte[] array = File.ReadAllBytes(files[i]);
string[] fn = files[i].Split(s);
long sizeOF = array.Length;
Header Vari = new Header();
Buffer.BlockCopy(array, 3220, Var2Bytes, 0, 2); //samples
int samples = Vari.Var2bytesInt(ref Var2Bytes);
Buffer.BlockCopy(array, 3224, Var2Bytes, 0, 2); //data sample format code
int fc = Vari.Var2bytesInt(ref Var2Bytes);
Buffer.BlockCopy(array, 3600+posS-1, Var4Bytes, 0, 4); //primer SP
fsp = Vari.Var4bytesInt(ref Var4Bytes);
Buffer.BlockCopy(array, 3600+posCMP-1, Var4Bytes, 0, 4); //primer cdp
fcdp = Vari.Var4bytesInt(ref Var4Bytes);
我要发送For循环中的变量“ i”的值。我以这种方式可以向用户显示进度,但是我不知道如何将此值发送到VBA,以及如何在VBA中获取它。 预先感谢您的帮助。