-
October 25th, 2013, 02:55 PM
#1
Visual Basic Coding Help: I have no idea what to do
I'm suffering from a case of, for lack of a better term, coder's block right. I need to work on this project but I have no idea how to start coding it, other than the immediate obvious.
The Display button's Click event procedure should read the five numbers stored in the numbers.txt file and display the numbers (one through five) in the list box, and the Update button's Click event procedure should read the same five numbers and store them in an array. It then should increase the numbers in the array by 1 and write the array contents to an empty numbers.txt file.
Here's what I've got right now:
Code:
Option Explicit On
Option Strict On
Option Infer Off
Public Class MainForm
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub displayButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles displayButton.Click
End Sub
Private Sub updateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles updateButton.Click
End Sub
End Class
And the list box is named numbersListBox.
-
October 25th, 2013, 03:16 PM
#2
Re: Visual Basic Coding Help: I have no idea what to do
Firstly... This looks exactly like homework...
Secondly, Your code has got nothing....
but here's links on how to do it...
#1 : open a text file
#2 : Display data in a listbox
#3 : adding data to an array
#4 : Writing to a text file
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
October 25th, 2013, 04:36 PM
#3
Re: Visual Basic Coding Help: I have no idea what to do
I could have gotten that very same information from my book, unfortunately it doesn't help in my current situation, considering that it only describes similar projects, and not like the sort of thing I'm looking for.
-
October 25th, 2013, 05:08 PM
#4
Re: Visual Basic Coding Help: I have no idea what to do
similar projects is all you need, if you have an example of how to read a file, place data in a list box, add to an array and write to a file then all your requirements are covered except the adding 1 to each value which really should not need to be explained.
Sure we could write the code for you in a few minutes but that defeats the purpose of the exercise and teaches you nothing.
You need to do 4 (5) things look at those links and try to write some code. If you run into trouble then post a related question
Always use [code][/code] tags when posting code.
-
October 25th, 2013, 06:03 PM
#5
Re: Visual Basic Coding Help: I have no idea what to do
Here's the updated code.
Code:
Option Explicit On
Option Strict On
Option Infer Off
Public Class MainForm
Dim loadedfile As String = "d:\test.txt"
Dim tempstr1 As String = IO.File.ReadAllText(loadedFile)
Private Sub MainForm_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Display_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Display.Click
numbersListBox.Items.Add(tempstr1)
End Sub
Private Sub update_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Update.Click
Dim x As Integer = tempstr1.Length - 1
Dim myarray(x) As String
Dim i As Integer = 0
For Each mychr As Char In tempstr1
myarray(i) = mychr
i += 1
ListBox2.Items.Add(i + 1)
Next
End Sub
End Class
Last edited by Moon_Dew; October 25th, 2013 at 08:25 PM.
-
October 25th, 2013, 09:10 PM
#6
Re: Visual Basic Coding Help: I have no idea what to do
I do not see a question
I do see that you are adding the whole file to the listbox rather than parsing out the numbers and adding each of them, can't say i have ever tried that to see what the result would be but I would be surprised if it worked.
not sure what you are trying to do in the loop but it is not close to what you said you wanted
You assign each char to the array then you add the index+1 to a list box?
Your OP says that you should add 1 to the values in the array and then write those to a new file.
Always use [code][/code] tags when posting code.
-
October 28th, 2013, 03:40 PM
#7
Re: Visual Basic Coding Help: I have no idea what to do
loadedfile is erased, isn't it?
-
October 28th, 2013, 08:44 PM
#8
Re: Visual Basic Coding Help: I have no idea what to do
Originally Posted by dglienna
loadedfile is erased, isn't it?
? why would you think that? There is no code there that writes to or deletes the file. All the text is read into tempstr1 and then he tries to add it all at once to the list box
Always use [code][/code] tags when posting code.
-
October 31st, 2013, 10:31 PM
#9
Re: Visual Basic Coding Help: I have no idea what to do
sorry. thought he was reading it again in the sub.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|