Compiling a Source Code
-
.
-
Member 13433022 wrote:
another person had written for me, since I am not a programmer.
Then the problem is, you will not understand what we are going to tell you. Thus, it would be best if you can approach them back and tell them that they have a problem with the code. It is obvious and common to have logical bugs, and programmers usually do solve them if the problem was by them (and not a requirement study problem). Lastly, the problem might be with the compiler flags, and the programmer who wrote the program may have a different setup for the compiler. I would again recommend, that you ask them for the procedure, as to how to build the project to test it.
The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~
-
Tell your friend to use the debugger to see exactly what the two lists contain at the end of the two reading loops.
I do not have the contact information of the person. I have compiled the source code in Visual Studio, and no errors were shown. The program starts normally but produces no results. Can you correct the source code so that it may do the task for which it is intended?
-
Option Strict On
Option Explicit On
Option Infer OffImports System.Collections.Generic
Imports System.IO
Imports System.Linq
Imports System.Windows.FormsPublic Class Form1
Private Sub _
Button1_Click(sender As System.Object,
e As System.EventArgs) _
Handles Button1.ClickDim inputFile1 As String = "C:\\New\\1.txt" Dim inputFile2 As String = "C:\\New\\2.txt" Dim outputFile As String = "C:\\New\\3.txt" Dim linesFile1 As IEnumerable(Of String) = File.ReadAllLines(inputFile1).Where(Function(line) Not \[String\].IsNullOrWhiteSpace(line)) Dim linesFile2 As IEnumerable(Of String) = File.ReadAllLines(inputFile2).Where(Function(line) Not \[String\].IsNullOrWhiteSpace(line)) Dim linesNotInFile2 As String() = linesFile1.Except(linesFile2).ToArray() File.WriteAllLines(outputFile, linesNotInFile2) End Sub
End Class
This should work. I wrote it in C# and had it automatically translated to Visual Basic.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
-
Option Strict On
Option Explicit On
Option Infer OffImports System.Collections.Generic
Imports System.IO
Imports System.Linq
Imports System.Windows.FormsPublic Class Form1
Private Sub _
Button1_Click(sender As System.Object,
e As System.EventArgs) _
Handles Button1.ClickDim inputFile1 As String = "C:\\New\\1.txt" Dim inputFile2 As String = "C:\\New\\2.txt" Dim outputFile As String = "C:\\New\\3.txt" Dim linesFile1 As IEnumerable(Of String) = File.ReadAllLines(inputFile1).Where(Function(line) Not \[String\].IsNullOrWhiteSpace(line)) Dim linesFile2 As IEnumerable(Of String) = File.ReadAllLines(inputFile2).Where(Function(line) Not \[String\].IsNullOrWhiteSpace(line)) Dim linesNotInFile2 As String() = linesFile1.Except(linesFile2).ToArray() File.WriteAllLines(outputFile, linesNotInFile2) End Sub
End Class
This should work. I wrote it in C# and had it automatically translated to Visual Basic.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
Hah I'd have done the foreach thing, did not occur to me to use linq. Have and upvote
Never underestimate the power of human stupidity RAH
-
I do not have the contact information of the person. I have compiled the source code in Visual Studio, and no errors were shown. The program starts normally but produces no results. Can you correct the source code so that it may do the task for which it is intended?
-
Hah I'd have done the foreach thing, did not occur to me to use linq. Have and upvote
Never underestimate the power of human stupidity RAH
Hehe, thanks :) I frequently have to stop myself from writing screen-long linq-stuff without intermediate results :laugh:
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
-
Hehe, thanks :) I frequently have to stop myself from writing screen-long linq-stuff without intermediate results :laugh:
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
Thank you for writing the code. It works after I compiled it into an .exe file. I understand how the “for” command works, repeating a certain operation a specified number of times. I was not aware of another way to achieve the same result.
-
Thank you for writing the code. It works after I compiled it into an .exe file. I understand how the “for” command works, repeating a certain operation a specified number of times. I was not aware of another way to achieve the same result.
You're welcome :) The methods I used there use (simply speaking) for-loops internally. It moves the ugly repetitive stuff out of sight.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson