• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

VB.net - Exact same code/program runs ok on 3 out of 4 identical computer setups

I have code/program that runs on four computers, basically just reads a text file.  It works on 3 of the 4 computers.  All computers are setup the same.

the exception that it throws on the one computer is index out of bounds.

Any idea why this would happen on just one and not the others.  When I debug the code step by step, all indexs are ok and not issues either.
  • 4
  • 2
2 Solutions
Dave BaldwinFixer of ProblemsCommented:
If the computers have been running for more than a week, they are no longer 'the same'.  Have you tried to debug the program on the computer that shows the problem?
Éric MoreauSenior .Net ConsultantCommented:
to they have the same regional settings?

do you know which line throws the exception?
keith1001Author Commented:
I don't have visual studio installed on these computers to debug, unless there is some other way?

Same regional settings on computers.

Here is the code part that is throwing the exception.

Sub ReadFileMachineCode()

        Dim x As Integer = 0
        Dim FileReader As StreamReader
        Dim filename As String
        Dim FileResultValues(8) As Integer
        filename = "c:\working\machinecodes\" & AutoCycle_MachineCode & ".csv"
        'MsgBox("Test:002" & AutoCycle_MachineCode)
            If AutoCycle_MachineCode <> "" Then
                FileReader = New StreamReader(filename)
                Do While Not FileReader.EndOfStream
                    'MsgBox("X= " & x)
                    Dim line As String = FileReader.ReadLine()
                    Dim fields() As String = line.Split(","c)
                    FileResultValues(x) = fields(1)
                    filevalue(x) = FileResultValues(x)
                    x = x + 1
            End If
        Catch ex As Exception
        End Try
    End Sub

Open in new window

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Éric MoreauSenior .Net ConsultantCommented:
add a couple of msgbox here and there to check the values of line, fields(), x, ... and you will find out exactly where and what is the cause.

without access to your PC, code and file, we can't do much!
keith1001Author Commented:
Understand on not seeing the issue directly.

I have added msgbox, i think you may see a couple commented out in the code above.  I will add more and try to get you guys more information later today.  
keith1001Author Commented:
Found my problem, thanks to NotePad++.

The windows stock notepad app was adding an extra CR+LF at the end of the file, once I was able to see that with Notepad++ and delete them, it fixed my problem.

Donation to Notepad++ on its way.

Thanks guys for helping out...
keith1001Author Commented:
had to also use notepad to investigate the file
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now