Hi
I've got a form in Visual Basic 2010 that has a Listview. Users insert something something into a textbox, click a button and then it goes into the listview. I need a way of saving this. I really don't care what format, it could be notepad or Excel for what I care.
Does anyone know how to do this? Any help would be appreciated.
8 replies to this topic
#1
Posted 30 November 2011 - 08:28 AM
|
|
|
#2
Posted 30 November 2011 - 08:43 AM
If you don't care what format its in, loop through the contents of the listView and write them to a .txt file, then save when done.
If you have problems post back.
~ Committed.
If you have problems post back.
~ Committed.
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.
#3
Posted 30 November 2011 - 08:45 AM
You mean type them in manually? I need the program to save it, as more will be added alot of the time, and I won't be the one who is using the program. Doesn't the Listview have an option of saving to any type of format?
#4
Posted 30 November 2011 - 08:56 AM
No I don't mean manually.
I mean something like this:
The above code is more C# than VB, and doesn't work, but that should give you an idea. If you don't know how to wright to a file try this: Visual Basic .NET programming for Beginners - How to Write to a Text File
~ Committed.
I mean something like this:
for(int i = 0; i < listView1.Length-1; i++)
{
write.toFile(listView1.Index(i))
}
The above code is more C# than VB, and doesn't work, but that should give you an idea. If you don't know how to wright to a file try this: Visual Basic .NET programming for Beginners - How to Write to a Text File
~ Committed.
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.
#5
Posted 30 November 2011 - 09:52 AM
create/open a file
use a for each, then save the items to the file.
close the file.
use a for each, then save the items to the file.
close the file.
#6
Posted 01 December 2011 - 12:53 AM
Cheers, I'll check it out later on and see how it works.
#7
Posted 02 December 2011 - 02:14 PM
For i As Integer = 0 To ListView1.Items.Count - 1
sw.Write(ListView1.Items(i).Text)
For subItemIndex As Integer = 1 To ListView1.Items(i).SubItems.Count - 1
sw.Write("testviewbox" & ListView1.Items(i).SubItems(subItemIndex).Text)
Next
sw.Write(Environment.NewLine)[/B]
Every time I try and save it anywhere on my hard drive, I get this error:
"Access to the path 'C:\Users\Francis\Documents' is denied.
Not only do I get this for this folder, though I also get it for C:\ and a folders.
I have also tried changing the settings in app.manifest to <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Is there any solution to this problem? Any help would once again be appreciated.
sw.Write(ListView1.Items(i).Text)
For subItemIndex As Integer = 1 To ListView1.Items(i).SubItems.Count - 1
sw.Write("testviewbox" & ListView1.Items(i).SubItems(subItemIndex).Text)
Next
sw.Write(Environment.NewLine)[/B]
Every time I try and save it anywhere on my hard drive, I get this error:
"Access to the path 'C:\Users\Francis\Documents' is denied.
Not only do I get this for this folder, though I also get it for C:\ and a folders.
I have also tried changing the settings in app.manifest to <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Is there any solution to this problem? Any help would once again be appreciated.
#8
Posted 02 December 2011 - 03:51 PM
I believe you may be running Windows7 or Vista. If so, run the program as Administrator.
Another thing, although it has nothing to do with your problem, you should use a foreach instead of a for loop whenever possible.
Another thing, although it has nothing to do with your problem, you should use a foreach instead of a for loop whenever possible.
#9
Posted 04 December 2011 - 09:24 AM
Resolved, I was only putting where to put the file, and not the file name.
Thanks for your help.
Francis.
Thanks for your help.
Francis.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









