|
-
Jan 18th, 2008, 02:56 AM
#1
Thread Starter
New Member
read *.xyz file
how to read the coordinate (xyz) from text files and display in VB as point graphic???
-
Jan 18th, 2008, 02:59 AM
#2
Re: read *.xyz file
You mean just read some data in a textfile?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 18th, 2008, 03:09 AM
#3
Thread Starter
New Member
-
Jan 18th, 2008, 05:42 AM
#4
Lively Member
Re: read *.xyz file
it all depends on your data file structure. please post a sample here.
-
Jan 18th, 2008, 12:52 PM
#5
Re: read *.xyz file
Change the numbers if its sensitive data but is it like a comma delimited file or just raw data all on a line?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 19th, 2008, 12:31 AM
#6
Thread Starter
New Member
Re: read *.xyz file
my data do not have delimited comma,all data separated by space and what do you mean by sensitive data.tq for the reply
-
Jan 19th, 2008, 01:11 AM
#7
Re: read *.xyz file
Sensitive data = data you don't want seen publicly (like corporate secrets or something).
Seeing a sample of the file structure helps greatly in developing a code that works. Also, if there is a picture of the final result of the very same sample, all the better.
If values are only separated with spaces then a simple Split will do the trick and the remaining problem is drawing the final result based on the values.
-
Jan 21st, 2008, 09:15 PM
#8
Thread Starter
New Member
Re: read *.xyz file
this is sample of my data...
X Y Z
627807.482 173582.422 135.091
627866.458 173516.968 125.675
627751.735 173598.406 134.672
627758.886 173607.705 135.808
can i read this data in VB and display as point graphic????
TQ....
-
Jan 21st, 2008, 09:58 PM
#9
Re: read *.xyz file
Well, I bothered to code this:
Code:
Public Sub LoadXYZ(ByRef Filename As String) As String()
Dim FF As Integer, lngA As Long, lngLen As Long
Dim bytBuffer() As Byte, strBuffer() As String
Dim strLine() As String, strOut() As String
' make sure the file exists
If LenB(Dir$(Filename, vbHidden)) Then
' make sure it has some data
lngLen = FileLen(Filename)
If lngLen Then
' read the file into a byte array
FF = FreeFile
Open Filename For Binary Access Read As #FF
ReDim bytBuffer(lngLen - 1)
Get #FF, , bytBuffer
Close #FF
' convert byte array to VB string format and split by line change
strBuffer = Split(StrConv(bytBuffer, vbUnicode), vbNewLine)
' memory cleanup
Erase bytBuffer
' see that this really is XYZ data
If strBuffer(0) = "X Y Z" And UBound(strBuffer) > 0 Then
' reserve enough space for output array
ReDim strOut(2, UBound(strBuffer) - 1)
' loop through all lines
For lngA = 1 To UBound(strBuffer)
' get line data
strLine = Split(strBuffer(lngA))
' number of items must be 3
If UBound(strLine) = 2 Then
' store into output array
strOut(0, lngA - 1) = strLine(0)
strOut(1, lngA - 1) = strLine(1)
strOut(2, lngA - 1) = strLine(2)
End If
Next lngA
' output final array
LoadXYZ = strOut
' we are done!
Exit Function
End If
End If
End If
' otherwise return an initialized empty array: UBound(LoadXYZ) = -1
LoadXYZ = Split(vbNullString)
End Sub
This outputs a string array which should be handled like this:
Code:
' load file
strResult = LoadXYZ("c:\text.xyz")
' valid data?
If UBound(strResult) = 2 Then
' should output "1: 627807.482 173582.422 135.091"
Debug.Print "1:", strResult(0, 0), strResult(1, 0), strResult(2, 0)
' 627866.458 173516.968 125.675
Debug.Print "2:", strResult(0, 1), strResult(1, 1), strResult(2, 1)
End If
Now you should, for the least, have the data so that you can use it to get started with the drawing. I don't know how to do that in this case, I don't know what the final result should look like, so that is for someone else to answer...
-
Jan 21st, 2008, 10:13 PM
#10
Thread Starter
New Member
Re: read *.xyz file
ok...TQ Merri...i will try this code....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|