Glenn,
Thanks for the info but most of it is Greek to me :-) I don't have a
programmer background and I'm not sure if I'm using VB or VB.net. I'm
using the Visual Studio Express (Free) software and have found samples
of code form Google Groups that I've pulled together to automate the
process. Very cool and fun stuff I just don't have a clue...
Here is my code. Maybe this will help:
Public Class Feature2Raster
Dim objPathIN
Dim objPathOUT
Dim objShell
Dim objFolder
Dim objFolderItem
Dim gp
Dim InCellSize
Dim TB5
Dim FCount As Integer
Dim HowLong As Integer
Dim FNameCUT
Dim FNameFinal
Dim oSF
Dim foldr
Dim fils
Dim FName
Dim InFeatures
Dim InField
Dim OutRaster
Dim Feat
Dim FeatTyp
Dim tm
Dim dt
Dim WhatChar
Dim FileExt
Public Sub btnDoFBD_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles InputFolder.Click
'Select Folder to read Shape Files from
Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0
objShell = CreateObject("Shell.Application")
objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select Input folder for Shape Files:",
NO_OPTIONS, "My Computer")
objFolderItem = objFolder.Self
objPathIN = objFolderItem.Path
TextBox3.Text = objPathIN
'Display next message in Message Center
TextBox5.Text = Nothing
TextBox5.Text = "Select Output Folder"
End Sub
Public Sub OutPutFolder_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles OutPutFolder.Click
'Select Folder for Output files
Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0
objShell = CreateObject("Shell.Application")
objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select Output folder for Raster Files:",
NO_OPTIONS, "My Computer")
objFolderItem = objFolder.Self
objPathOUT = objFolderItem.Path
TextBox4.Text = objPathOUT
'Display next message in Message Center
TextBox5.Text = Nothing
TextBox5.Text = "Keyin All Feature related info and Select
Process Button"
End Sub
Public Sub btnExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExit.Click
'End Program
End
End Sub
Public Sub Main()
' Create the Geoprocessor object
gp = CreateObject("esriGeoprocessing.GPDispatch.1")
' Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/
Conversion Tools.tbx")
'Read files in selected folder
'Set Time/Day Stamp for begin Process
tm = TimeOfDay
dt = DateString
'Display next message in Message Center - this does not work
TextBox5.Text = Nothing
TextBox5.Text = "Proccessing...Please Wait..."
'Create Log File
Dim FSO, MyLogFile
FSO = CreateObject("Scripting.FileSystemObject")
MyLogFile = FSO.CreateTextFile(objPathOUT &
"\Feature2RasterFile.log")
'Write Start Time to Log File
With MyLogFile
.Write("Feature2Raster Processing Started @ " & dt & " " &
tm & vbCrLf & vbCrLf)
End With
'Get Input Folder
oSF = CreateObject("Scripting.FileSYStemOBJect")
foldr = oSF.GetFolder(objPathIN)
fils = foldr.Files
FName = ""
FCount = 0
'Define Default Parameters
'InCellSize = "3.5"
InCellSize = TextBox1.Text
'InField = "coord_z"
InField = TextBox2.Text
'Feat = "flora"
Feat = TextBox7.Text
'FeatTyp = "flora_species_point"
FeatTyp = TextBox8.Text
'FeatExt = "img"
FileExt = TextBox6.Text
'Write Parameters to Log File
With MyLogFile
.Write("Processing Parameters are listed below: " &
vbCrLf)
.Write("Input Folder: " & objPathIN & vbCrLf)
.Write("Output Folder: " & objPathOUT & vbCrLf)
.Write("Output File Extension: ." & FileExt & vbCrLf)
.Write("Feature: " & Feat & vbCrLf)
.Write("Feature Type: " & FeatTyp & vbCrLf)
.Write("Field: " & InField & vbCrLf)
.Write("Cell Size: " & InCellSize & vbCrLf & vbCrLf)
End With
'Process each Input File
For Each fL In fils
FCount = FCount + 1
FName = fL.Name
'InFeatures = objPathIN & "\" & FName & "\flora
\flora_species_point"
InFeatures = objPathIN & "\" & FName & "\" & Feat & "\" &
FeatTyp
'Trim Filename for Output File Name
WhatChar = "."
HowLong = Len(FName) - 4
'FNameCUT = Mid(FName, InStrRev(FName, WhatChar) -
HowLong)
FNameCUT = Mid(FName, 1, HowLong) & "." & FileExt
'Set Output File
'OutRaster = objPathOUT & "\" & FNameCUT & ".img"
OutRaster = objPathOUT & "\" & FNameCUT
'MsgBox("FName(FCount) are : " & vbCrLf &
"-----------------" & vbCrLf & arg3) '- - --------------------------
'Write Input & Output File Names to Log File
With MyLogFile
.Write("Feature2Raster Processing Input: " & FName &
vbCrLf)
'.Write("Feature2Raster Processing Output: " &
FNameCUT & ".img" & vbCrLf)
.Write("Feature2Raster Processing Output: " & FNameCUT
& vbCrLf)
End With
' Process: Feature to Raster...
gp.FeatureToRaster_conversion(InFeatures, InField,
OutRaster, InCellSize)
Next
'ReSet Time/Day Stamp for End Process
tm = TimeOfDay
dt = DateString
'Write Time/Day Stamp for End Process
With MyLogFile
.Write(vbCrLf)
.Write("Feature2Raster Processing Completed @ " & dt & " "
& tm)
.Close()
End With
MyLogFile = Nothing
FSO = Nothing
'MsgBox("There are " & FCount & " files Process from folder "
& objPathIN)
'MsgBox("File Names are : " & vbCrLf & "-----------------" &
vbCrLf & FName) '- - --------------------------
End Sub
Public Sub Process_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Process.Click
'Display next message in Message Center - this does not work
TextBox5.Update()
TextBox5.Text = Nothing
TextBox5.Text = "Proccessing...Please Wait..."
StartProcess()
'Call Main Program
Main()
'Display next message in Message Center
TextBox5.Text = Nothing
TextBox5.Text = "Process Complete with " & FCount & " files
processed"
End Sub
Public Sub StartProcess()
'Display next message in Message Center - this does not work
TextBox5.Text = Nothing
TextBox5.Text = "Proccessing...Please Wait..."
End Sub
Public Sub TextBox1_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Public Sub TextBox2_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox2.TextChanged
End Sub
Public Sub TextBox3_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox3.TextChanged
End Sub
Public Sub TextBox4_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox4.TextChanged
End Sub
Public Sub TextBox6_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox6.TextChanged
End Sub
Public Sub TextBox7_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox7.TextChanged
End Sub
Public Sub TextBox8_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox8.TextChanged
End Sub
Public Sub TextBox9_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox9.TextChanged
End Sub
Public Sub TextBox3_Enter(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox3.TextChanged
' If the TextBox contains text, change its foreground and
background colors.
If TextBox3.Text = [String].Empty Then
TextBox3.Text = "Please Select Input Folder"
TextBox3.ForeColor = Color.Red
TextBox3.BackColor = Color.White
' Move the selection pointer to the end of the text of the
control.
TextBox3.Select(TextBox3.Text.Length, 0)
End If
End Sub
Public Sub Feature2Raster_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
'Display Input File path
TextBox3.Text = objPathIN
'Display Output File path
TextBox4.Text = objPathOUT
'Display next message in Message Center
TextBox5.Text = "Please Fill-in Form Top Down"
End Sub
End Class
On Aug 28, 6:19 am, Glenn <[EMAIL PROTECTED]> wrote:
> First of all, are you talking VB or VB.NET? VB <> VB.NET! From the looks
> of it, you're talking VB.
>
> Secondly, your control will not update until the event is handled by the
> program. If you update the control in the beginning of an event handler, it
> won't get updated until the event handler finishes. This is because the GUI
> thread will only processing one event at a time.
>
> The progress/status bar is your best place for updates. Dig into it and
> you'll get it. If you're using VB, get Visual Studio Express 2008 and start
> using VB.NET. Progress/Status bars are easier in VB.NET than they were in
> VB.
>
> If you have functionality that takes a long time to perform, you should put
> it in a background thread and use a Delegate to update the GUI. You should
> return control to the user as soon as possible so that you program is more
> responsive to the user.
>
> ...Glenn
>
>
>
> On Wed, Aug 27, 2008 at 5:28 PM, WynnGIS <[EMAIL PROTECTED]> wrote:
>
> > Hello!
>
> > I'm new to VB and need some help.
>
> > 1st: I'm I posting to the correct group?
>
> > 2nd: I have a small VB Form Program to do batch process for
> > converting files in ArcGIS. The processing works well but I need to
> > make enhancements.
>
> > I'm trying to do process monitoring via a textbox (TextBox5.Text). In
> > some parts of the code the textbox is updated and in other location it
> > is not. For example, in the Subs btnDoFBD_Click and
> > OutPutFolder_Click works but in the Main Sub this text box is not
> > being up dated. For example,
>
> > 'Display next message in Message Center - this does not work
> > TextBox5.Text = Nothing
> > TextBox5.Text = "Proccessing...Please Wait..."
>
> > I understand that this code could be written more efficient and I'm
> > open to suggestion. I've pulled it together from example off Google
> > Groups and surprisingly it work. I don't know which controls are best
> > used in which situation but would really like to learn.
>
> > Can someone tell me why this textbox is not being updated? Can you
> > tell me if there's a better way to do Process Monitoring. I've
> > searched for examples of "Progress Bar" but can not find any that I
> > can understand and implement. A good example would be helpful.
>
> > 3rd: I have a Sub "btnDoFBD_Click" to input the data for this
> > process. I select the Input Folder via this Click event and display
> > the selected folder in TextBox3.Text = objPathIN and all works well
> > but TextBox3.Text is only for display. Is there another control that
> > will allow me to keyin the Input and/or select it from a button or
> > pull-down?
>
> > Thanks for your help in advance.
>
> > Tim- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---