Below is a code snippet that exists in my VB2010 program. I accessed it using the search function and the word "holding". It found the word near the bottom of the snippet. It (the strange place that I have not seen/remember how I created it before) appears to be associated with my form4 (but is not code that appears on form4), as per the second line down in the snippet.
There is something that I wish to replicate (have the OpenFileDialog automatically come up with a default filename),on another form, but as per the comments in the snippet, it must be done with: 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor.
The code I wish to replicate and use is found 3 lines up from the bottom of the snippet: "Me.OpenFileDialog1.FileName = "C:\holding"" ,which opens the FileDialog with the path and file name as indicated.
When I go to the Form Designer (the graphical representation of the form), I cannot find any way of creating/editing to create a similar function on another form (it does not appear to be in the "properties"). The associated code I have on the button that enables OpenFileDialog1 on form4 is below the asterisks beneath the code snippet.
Note: I am 70 years old and have not worked on this project in about two years; have patience and explain very simply please.
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form4
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.TextBox2 = New System.Windows.Forms.TextBox()
.
'Button4
'
Me.Button4.Location = New System.Drawing.Point(527, 480)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(170, 48)
Me.Button4.TabIndex = 6
Me.Button4.Text = "Clear Both Text Boxes"
Me.Button4.UseVisualStyleBackColor = True
'
'OpenFileDialog1
'
Me.OpenFileDialog1.DefaultExt = "txt"
Me.OpenFileDialog1.FileName = "C:\holding"
Me.OpenFileDialog1.InitialDirectory = "C:\"
Me.OpenFileDialog1.Title = "File to be Decrypted"
'************************************************************************
'The code that is on the button control on form4
'*************************************************************************
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.ShowDialog = System.Windows.Forms.DialogResult.OK Then
' Reads the contents of the text file into TextBox2.
TextBox2.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
End If
There is something that I wish to replicate (have the OpenFileDialog automatically come up with a default filename),on another form, but as per the comments in the snippet, it must be done with: 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor.
The code I wish to replicate and use is found 3 lines up from the bottom of the snippet: "Me.OpenFileDialog1.FileName = "C:\holding"" ,which opens the FileDialog with the path and file name as indicated.
When I go to the Form Designer (the graphical representation of the form), I cannot find any way of creating/editing to create a similar function on another form (it does not appear to be in the "properties"). The associated code I have on the button that enables OpenFileDialog1 on form4 is below the asterisks beneath the code snippet.
Note: I am 70 years old and have not worked on this project in about two years; have patience and explain very simply please.
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form4
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.TextBox2 = New System.Windows.Forms.TextBox()
.
'Button4
'
Me.Button4.Location = New System.Drawing.Point(527, 480)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(170, 48)
Me.Button4.TabIndex = 6
Me.Button4.Text = "Clear Both Text Boxes"
Me.Button4.UseVisualStyleBackColor = True
'
'OpenFileDialog1
'
Me.OpenFileDialog1.DefaultExt = "txt"
Me.OpenFileDialog1.FileName = "C:\holding"
Me.OpenFileDialog1.InitialDirectory = "C:\"
Me.OpenFileDialog1.Title = "File to be Decrypted"
'************************************************************************
'The code that is on the button control on form4
'*************************************************************************
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.ShowDialog = System.Windows.Forms.DialogResult.OK Then
' Reads the contents of the text file into TextBox2.
TextBox2.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
End If