473,322 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

OpenFileDialog and saving files

I have a form in my project, which I open as a DialogBox. On that that
form there are 3 TextBoxes. To one of them I want to write in a file
path. To have it easier I have an OpenFileDialog control on my form.
Selected file path is written in to th TextBox. OpenFileDialog is open
by click on a Button.

There is other Button on the form run the code which save every form
field to a file.

When I manualy fill all fields in form everything is OK, but when i
choose the file path by mean of OpenFileDialog, nothing is save to the
file. Even file is not created. That happend when i confirm selected
file in OpenFileDialog, but if I press Cancel and than maualy fill the
TextBox in program saves data properly to file.

Where is the problem? And how can I solve it.

Code for the button which activate OpenFileDialog:

Private Sub btnLogFileSourceBrowse_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnLogFileSourceBrowse.Click
ofdFiles.Title = "Select log file"
ofdFiles.Multiselect = False

If ofdFiles.ShowDialog = Windows.Forms.DialogResult.OK Then
txtLogFileSource.Text = ofdFiles.FileName
End If
End Sub

Code for button whoch saves data
Private Sub btnProjectDetailsAccept_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnProjectDetailsAccept.Click
'Set True value indicating that form was submited...
AcceptedOnce = True

'Check form to find any empty fields. If every field is filled
process to save data...
If CheckIfFilled() = True Then

'Create a new project data...
Dim newProject As ProjectDataSettings
newProject =
LogTeller.frmLogTellerMain.ProjectsBook.AddProject DataSettings

'Set current number of elements in ProjectsBook as the
current index...
LogTeller.frmLogTellerMain.CurrentProjectIndex =
LogTeller.frmLogTellerMain.ProjectsBook.Items.Coun t

'Write data from form to project's properties...

UpdateCurrentProject(LogTeller.frmLogTellerMain.Cu rrentProject)

'Remove empty objects from collections...
LogTeller.frmLogTellerMain.ProjectsBook.RemoveEmpt y()

'If there is not any object in colection, add one empty...
If LogTeller.frmLogTellerMain.ProjectsBook.Items.Coun t = 0
Then LogTeller.frmLogTellerMain.ProjectsBook.AddProject DataSettings()

'Save data to file...
LogTeller.frmLogTellerMain.SaveChanges()

'Clear all fields in the form...
ClearForm()

'Close the form...
Me.Close()

AcceptedOnce = False
End If

End Sub

Code which copies date from form to object:
Public Sub UpdateCurrentProject(ByVal project As ProjectDataSettings)
'Copy data...
project.ProjectName = txtProjectName.Text
project.DomainName = txtDomainName.Text
project.LogFileSource = txtLogFileSource.Text
End Sub
May 17 '06 #1
0 1165

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Lina | last post by:
Hello, I wanted to ask if anyone can help me complete the following code. I found this example while searching through help documnets. What i want to achieve is to open a dialog box that lets...
11
by: Mr. B | last post by:
If you can set the 'initial' path of an OpenFileDialog box by something like the following: Dim FilesPath As String ' Files Path FilesPath = "P:\Projects\" FilesPath =...
4
by: Nagachandra Sekhar Grandhi | last post by:
I am facing a problem with OpenFileDialog. It is as follows. I opened OpenFileDialog dialog box and selected a folder in it. After selecting the folder when i tried to delete the same folder in...
1
by: Olaf Baeyens | last post by:
In .NET v1.1 I am trying to select multiple files using OpenFileDialog like this OpenFileDialog openFileDialog=new OpenFileDialog(); openFileDialog.Multiselect=true; i...
1
by: Matthew | last post by:
The code is here: http://www.osbornewood.com/matthew/vb.cfm I am trying to Serialize soundFile.Text to an XML file. I have two buttons: Browse and Save Settings. You can enter a value the...
6
by: barbara_dave | last post by:
Hi, All, I want to use the openfiledialog to open different extension files in different directory( only one type files at one time). I set the OpenFiledialog InitialDirectory and Filter...
8
by: marcus.kwok | last post by:
I am having a weird problem and I have can't figure out why it is happening. I create an OpenFileDialog and set a filename filter. When the dialog first opens, the filter works correctly, and...
6
by: Mike | last post by:
Hello all, I'm trying to work with the openfiledialog and being new to vb and vb.net I'm having some problems. Wherever I have Me.OpenFileDialog1 I keep getting the following error: C:\Visual...
8
by: Z.K. | last post by:
I would like to display two different types of files when bringing up the OpenFileDialog, but I can't seem to figure out how to do this. I can manage a single file type or all file types, but not...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.