Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Tracy Excell
Front End Web Development Techdegree Graduate 15,333 PointsVisual Basic
Hi I am doing a Visual Basic section of a course and as it it not featured on here, I am having a hard time learning to code it. I am also getting conflicting information about how to code from the web. Is there anyone confident in this that wouldn't mind answering a few basic questions for me from time to time, to help me get through this section?
2 Answers
Timothy Showler
Courses Plus Student 185 PointsI have some basic knowledge in vb.net. Whats the question?
Timothy Showler
Courses Plus Student 185 PointsOk from you're question and my understanding, what you posted won't work as you have 2 things trying to do the same thing at once.
Example in your Button1_Click event you have this ;
Dim oStr As StreamWriter = File.CreateText("myFile.txt") Dim iStr As StreamReader = File.OpenText("myfile.txt")
Since it is in the one button event, its going to try create the file as well as open the file. So it is being used and can't be opened.
I haven't touched VB in a while, but if you give me a few minutes I will try and re-produce this for you and fix it up :)
Edit: I just saw the part to which I just explained haha my bad!
Tracy Excell
Front End Web Development Techdegree Graduate 15,333 PointsThank you,
I will have a play around tonight with it, and if you do not mind ask you if I hit a wall. Thank you for your help it is much appreciated.
Tracy Excell
Front End Web Development Techdegree Graduate 15,333 PointsHi Timothy,
Sorry to bother you again. Do you understand why this code is not working? I am attempting to make a calculator following instructions, but seem to have missed something. The internet is not helping me work this one out!
Public Class Form1
Dim total As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
total = AddNumbers(CInt(TextBox1.Text), total)
End Sub
Private Function AddNumbers(ByVal x As Integer, ByVal t As Integer)
t = t + x
Return t
End Function
' AddNumbers(ByVal x As Integer, ByRef t As Integer)
' AddNumbers(CInt(TextBox1.Text), total)
End Class
The invalid message states: Conversion from string "6 + 2" to type 'Integer' is not valid.
Tracy Excell
Front End Web Development Techdegree Graduate 15,333 PointsTracy Excell
Front End Web Development Techdegree Graduate 15,333 PointsHi Timothy,
Thank you. My task is to create a simple text editor application where existing files can be opened and new files can be written. I have watched a bit on you tube and read the course notes. My code so far is attached below, but I am confused with what syntax needs to be in place to read and write correctly. Any advice is appreciated. also is C# what Visual Basic uses?
Imports System.IO
Public Class Form1
End Class