Note that there are some explanatory texts on larger screens.

plurals
  1. POError: A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
    primarykey
    data
    text
    <p>I'm working on a simple Matching Algorithm. I'm quite new to programming and don't quite understand the error im getting.</p> <p>The File.txt contains data in this format (without the spaces between each line):</p> <pre><code>5,Name,9,9,9,9 4,Name,4,8,0,3 3,Name,4,7,3,5 2,Name,3,5,6,3 1,Name,5,8,2,9 0,Name,2,5,3,2 </code></pre> <p>"A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll</p> <p>Additional information: Conversion from string "" to type 'Integer' is not valid."</p> <p>The error occures for "CustomNrOld = splits(0)" and I don't see why.</p> <p>Would be happy about any kind of help!!</p> <pre><code>Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim CustomNrNew As Integer Dim NameIDnew As String Dim Alphanew As Integer Dim Betanew As Integer Dim Gammanew As Integer Dim Deltanew As Integer Dim CustomNrOld As Integer Dim NameIDold As String Dim Alphaold As Integer Dim Betaold As Integer Dim Gammaold As Integer Dim Deltaold As Integer Dim R1 As Integer Dim R2 As Integer Dim R3 As Integer Dim R4 As Integer Using sr As New StreamReader("C:\\Users\\Paul\\Documents\\Weever\\file.txt") Dim splits As String() = sr.ReadLine.Split(","c) CustomNrNew = splits(0) NameIDnew = splits(1) Alphanew = splits(2) Betanew = splits(3) Gammanew = splits(4) Deltanew = splits(5) End Using Using sr As New StreamReader("C:\\Users\\Paul\\Documents\\Weever\\file.txt") sr.ReadLine() Do While Not sr.EndOfStream Dim splits As String() = sr.ReadLine.Split(","c) CustomNrOld = splits(0) NameIDold = splits(1) Alphaold = splits(2) Betaold = splits(3) Gammaold = splits(4) Deltaold = splits(5) If Alphanew &gt;= Alphaold = True Then R1 = (Alphaold / Alphanew) * 100 Else R1 = (Alphanew / Alphaold) * 100 End If If Betanew &gt;= Betaold = True Then R2 = (Betaold / Betanew) * 100 Else R2 = (Betanew / Betaold) * 100 End If If Gammanew &gt;= Gammaold = True Then R3 = (Gammaold / Gammanew) * 100 Else R3 = (Gammanew / Gammaold) * 100 End If If Deltanew &gt;= Deltaold = True Then R4 = (Deltaold / Deltanew) * 100 Else R4 = (Deltanew / Deltaold) * 100 End If Dim Result As Integer Result = ((R1 + R2 + R3 + R4) / 4) My.Computer.FileSystem.WriteAllText("C:\\Users\\Paul\\Documents\\Weever\\" &amp; NameIDnew &amp; ".txt", Result &amp; "%" &amp; " - " &amp; NameIDold &amp; " " &amp; R1 &amp; "% / " &amp; R2 &amp; "% / " &amp; R3 &amp; "% / " &amp; R4 &amp; "% " &amp; Environment.NewLine, True) My.Computer.FileSystem.WriteAllText("C:\\Users\\Paul\\Documents\\Weever\\" &amp; NameIDold &amp; ".txt", Result &amp; "%" &amp; " - " &amp; NameIDnew &amp; " " &amp; R1 &amp; "% / " &amp; R2 &amp; "% / " &amp; R3 &amp; "% / " &amp; R4 &amp; "% " &amp; Environment.NewLine, True) Loop End Using </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload