DR00ME Posted March 23, 2004 Posted March 23, 2004 Private Sub btnCalibrate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalibrate.Click Dim CalibFile As FileStream CalibFile = New FileStream("Calibration.ini", FileMode.Create) Dim i As Integer Dim byteArray() As Byte Dim dataString As String For i = 0 To lstHSL.Items.Count() - 1 dataString = dataString + lstHSL.Items(i) Next i byteArray = Encoding.Unicode.GetBytes(dataString) 'This is the problematic part CalibFile.Write(byteArray, 0, byteArray.Length) CalibFile.Close() CalibFile = Nothing End Sub "String reference is not set to an instance of a string" Quote "Everything should be made as simple as possible, but not simpler." "It's not that I'm so smart , it's just that I stay with problems longer ." - Albert Einstein
Administrators PlausiblyDamp Posted March 23, 2004 Administrators Posted March 23, 2004 If you step through the code what happens in the For i = 0 To lstHSL.Items.Count() - 1 dataString = dataString + lstHSL.Items(i) Next i part? Does the string build up correctly? Did you mean to use '&' instead of '+' in the loop? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
DR00ME Posted March 23, 2004 Author Posted March 23, 2004 I have allways thought & is same as + ? ...anyway I tried '&' with the same result... I got same error... have to investigate whats going on... Quote "Everything should be made as simple as possible, but not simpler." "It's not that I'm so smart , it's just that I stay with problems longer ." - Albert Einstein
Administrators PlausiblyDamp Posted March 23, 2004 Administrators Posted March 23, 2004 Is the dataString building up in the loop though? What is the value of lstHSL.Items.Count? Try putting Option Strict On at the top of the source file and fix any errors that get generated. Also what does lstHSL(i) evaluate to in each itteration of the loop? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
DR00ME Posted March 23, 2004 Author Posted March 23, 2004 ROFL, a good point actually I didn't have anytihng in the listbox :DDDD *Bangs his head on the wall* *Bangs his head on the wall* *Bangs his head on the wall* *Bangs his head on the wall* *Bangs his head on the wall* Quote "Everything should be made as simple as possible, but not simpler." "It's not that I'm so smart , it's just that I stay with problems longer ." - Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.