rafl
Mechanical
- May 30, 2011
- 41
I'm working on a journal that would get the largest number from file names in specified folder and display the result in a listing window. This is what I got so far:
Any help would be appreciated.
Code:
Option Strict Off
Imports NXOpen
Imports System
Imports System.IO
Imports System.Windows.Forms
Module list_files
Sub Main()
Dim s As Session = Session.GetSession()
Dim lw As ListingWindow = s.ListingWindow()
'Dim foldername As String = ""
Dim dir As DirectoryInfo = new DirectoryInfo("D:\test")
Dim fsi As FileSystemInfo
Dim Filename As String
lw.Open()
For Each fsi In dir.GetFileSystemInfos("*.prt")
If (TypeOf fsi is FileInfo) Then
Dim f As FileInfo = CType( fsi, FileInfo )
Dim Intf As Integer
Filename = f.Name
Intf = MakeInt(Filename)
lw.WriteLine(Intf)
End If
Next fsi
End Sub
Public Function MakeInt(ByVal stringint As String) As String
Dim lngCount As Long
Dim strOut As String
if Len(stringint) > 0 then
for lngCount = 1 to len(stringint)
if isnumeric(mid$(stringint, lngCount, 1)) then
strOut = strOut & mid$(stringint, lngCount, 1)
end if
next lngCount
end if
MakeInt = strOut
End Function
End Module
Any help would be appreciated.