i was given a practice code and when i executed the code everything went well. now when i deleted the CStr from a label it was assigned to, i noticed that the program did not do anything different, everything went well as it should have, unless i didnt check somewhere i was supposed to?
for example in my code.....
so again i ask why do we need or what is the importance of CStr?Code:Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ListBox1.Items.Add("COMP 2110") ListBox1.Items.Add("COMP 2120") ListBox1.Items.Add("COMP 2300") ListBox1.Items.Add("COMP 2315") ListBox1.Items.Add("COMP 2400") ListBox1.Items.Add("COMP 2501") ListBox1.Items.Add("GEIC 1000") End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim num As Integer Dim Count As Integer Dim file_courses As IO.StreamWriter = IO.File.CreateText("Courses.dat") Label1.Text = CStr(ListBox1.Items.Count)//when i deleted this CStr nothing different happened? what was supposed to happen? For num = 0 To (ListBox1.Items.Count) file_courses.Write(ListBox1.Items(Count)) Next file_courses.Close() End Sub End Class




Reply With Quote
