Hi Bruce, I took a few minutes and looked at your code. I have some comments. I have no tried these ideas so they may or may not work but it's worth a shot. VB.Net has the ability to use either 0 or 1-based arrays. The first thing I noticed is that you are using Dim dbFields(4) As DBFFieldInfo You might want to use using dbFields(5) instead. This way you use indices 0 thru 4. The DBF writer is C# and I'm not sure how would it handle this situation. The second thing I noticed is that you are using whole numbers without decimals for assigning your double variables. I recommend, if only for consistency, to use a true double value like 1.0 or 0.0 instead of 1 or 0. I don't know if this would make a difference or not. I checked our own code for when we export to Shapefile from a FlexTable and we create the DBFFieldInfo a little bit differently. In addition we add an instance of DBFFieldInfo to an ArrayList and then use ToArray() to create the array. In my example here I'll use a generic list instead. Note that this is C# code, not VB.Net code (you should get the gist of the idea though). List fields = new List (); DBFFieldInfo field = new DBFFieldInfo(); field.FieldName = "MonYr"; field.FieldType = DBFFieldType.String; if(field.FieldType == DBFFieldType.String) field.FieldLength = DBFFieldType.MaxTextFieldLength; //You were actually missing this setting. fields.Add(field); You could easily refactor the code above between the creation of the List<> and the Add call into a method. You could pass in the fieldname and type and return the resulting object. Then you could do something like this: fields.Add(Newfield("MonYr", DBFFieldType.String)); Then once your fields are added, you can initialize the writer like this: if (shpWriter.CreateDataFile(pathShpFile, fields.ToArray(), true, ShapeType.Polyline)) ... In this case you would know for sure the exact number of elements are in the array when it is passed to the function. I hope that helps. Kris Culin Bentley Software Development
↧