how to find which line is missing “{” “}”












0















I want to make a program like Missing Bracket Finder, and I make it, but I want the program to tell me which in line is missing { or }, I'm totally beginner, sorry for my bad english.



This is my code:



Public Class Form1

Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
TextBox1.Text = OpenFileDialog1.FileName
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If System.IO.File.Exists(OpenFileDialog1.FileName) Then
MsgBox("Number '{':" & System.IO.File.ReadAllText(OpenFileDialog1.FileName).Count(Function(x) x = "{") & " " & "Number '}':" & System.IO.File.ReadAllText(OpenFileDialog1.FileName).Count(Function(x) x = "}"), MsgBoxStyle.OkOnly, "Info")
Else
MsgBox(TextBox1.Text & vbNewLine & "File not found." & vbNewLine & "Please verify the correct file name was given.", MsgBoxStyle.Exclamation, "Open")
End If
End Sub

End Class









share|improve this question

























  • Please learn about the Stack data structure. This is a classic problem solved by stacks.

    – Yakov Dan
    Jan 1 at 21:30
















0















I want to make a program like Missing Bracket Finder, and I make it, but I want the program to tell me which in line is missing { or }, I'm totally beginner, sorry for my bad english.



This is my code:



Public Class Form1

Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
TextBox1.Text = OpenFileDialog1.FileName
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If System.IO.File.Exists(OpenFileDialog1.FileName) Then
MsgBox("Number '{':" & System.IO.File.ReadAllText(OpenFileDialog1.FileName).Count(Function(x) x = "{") & " " & "Number '}':" & System.IO.File.ReadAllText(OpenFileDialog1.FileName).Count(Function(x) x = "}"), MsgBoxStyle.OkOnly, "Info")
Else
MsgBox(TextBox1.Text & vbNewLine & "File not found." & vbNewLine & "Please verify the correct file name was given.", MsgBoxStyle.Exclamation, "Open")
End If
End Sub

End Class









share|improve this question

























  • Please learn about the Stack data structure. This is a classic problem solved by stacks.

    – Yakov Dan
    Jan 1 at 21:30














0












0








0


0






I want to make a program like Missing Bracket Finder, and I make it, but I want the program to tell me which in line is missing { or }, I'm totally beginner, sorry for my bad english.



This is my code:



Public Class Form1

Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
TextBox1.Text = OpenFileDialog1.FileName
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If System.IO.File.Exists(OpenFileDialog1.FileName) Then
MsgBox("Number '{':" & System.IO.File.ReadAllText(OpenFileDialog1.FileName).Count(Function(x) x = "{") & " " & "Number '}':" & System.IO.File.ReadAllText(OpenFileDialog1.FileName).Count(Function(x) x = "}"), MsgBoxStyle.OkOnly, "Info")
Else
MsgBox(TextBox1.Text & vbNewLine & "File not found." & vbNewLine & "Please verify the correct file name was given.", MsgBoxStyle.Exclamation, "Open")
End If
End Sub

End Class









share|improve this question
















I want to make a program like Missing Bracket Finder, and I make it, but I want the program to tell me which in line is missing { or }, I'm totally beginner, sorry for my bad english.



This is my code:



Public Class Form1

Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
TextBox1.Text = OpenFileDialog1.FileName
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If System.IO.File.Exists(OpenFileDialog1.FileName) Then
MsgBox("Number '{':" & System.IO.File.ReadAllText(OpenFileDialog1.FileName).Count(Function(x) x = "{") & " " & "Number '}':" & System.IO.File.ReadAllText(OpenFileDialog1.FileName).Count(Function(x) x = "}"), MsgBoxStyle.OkOnly, "Info")
Else
MsgBox(TextBox1.Text & vbNewLine & "File not found." & vbNewLine & "Please verify the correct file name was given.", MsgBoxStyle.Exclamation, "Open")
End If
End Sub

End Class






basic






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 21:15









Nisse Engström

4,16292135




4,16292135










asked Jan 1 at 20:32









rizlarizla

1




1













  • Please learn about the Stack data structure. This is a classic problem solved by stacks.

    – Yakov Dan
    Jan 1 at 21:30



















  • Please learn about the Stack data structure. This is a classic problem solved by stacks.

    – Yakov Dan
    Jan 1 at 21:30

















Please learn about the Stack data structure. This is a classic problem solved by stacks.

– Yakov Dan
Jan 1 at 21:30





Please learn about the Stack data structure. This is a classic problem solved by stacks.

– Yakov Dan
Jan 1 at 21:30












1 Answer
1






active

oldest

votes


















-1














yes hi,
This is an easy trick, common and used everywhere in those programs and debuggers. You just set a counter for each type of braces, add 1 when it's '{' and substract one on the opposite direction. Line you won't get, but approximate solution will work once you reach out negative values, you should always get 0 in the end and never have negatives. If you want line anyway, just only empty spaces. Count empty spaces and work out your braces counting along with that, but it's not recommended.






share|improve this answer
























  • can you give me example

    – rizla
    Jan 1 at 20:48











  • Let it one and half year from now, I believe it is not slightly the time for you. I can describe the solution as I said in one sentence, but the code is usually not one sentence at all.

    – Vitali Pomanitski
    Jan 1 at 21:52











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53998739%2fhow-to-find-which-line-is-missing%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









-1














yes hi,
This is an easy trick, common and used everywhere in those programs and debuggers. You just set a counter for each type of braces, add 1 when it's '{' and substract one on the opposite direction. Line you won't get, but approximate solution will work once you reach out negative values, you should always get 0 in the end and never have negatives. If you want line anyway, just only empty spaces. Count empty spaces and work out your braces counting along with that, but it's not recommended.






share|improve this answer
























  • can you give me example

    – rizla
    Jan 1 at 20:48











  • Let it one and half year from now, I believe it is not slightly the time for you. I can describe the solution as I said in one sentence, but the code is usually not one sentence at all.

    – Vitali Pomanitski
    Jan 1 at 21:52
















-1














yes hi,
This is an easy trick, common and used everywhere in those programs and debuggers. You just set a counter for each type of braces, add 1 when it's '{' and substract one on the opposite direction. Line you won't get, but approximate solution will work once you reach out negative values, you should always get 0 in the end and never have negatives. If you want line anyway, just only empty spaces. Count empty spaces and work out your braces counting along with that, but it's not recommended.






share|improve this answer
























  • can you give me example

    – rizla
    Jan 1 at 20:48











  • Let it one and half year from now, I believe it is not slightly the time for you. I can describe the solution as I said in one sentence, but the code is usually not one sentence at all.

    – Vitali Pomanitski
    Jan 1 at 21:52














-1












-1








-1







yes hi,
This is an easy trick, common and used everywhere in those programs and debuggers. You just set a counter for each type of braces, add 1 when it's '{' and substract one on the opposite direction. Line you won't get, but approximate solution will work once you reach out negative values, you should always get 0 in the end and never have negatives. If you want line anyway, just only empty spaces. Count empty spaces and work out your braces counting along with that, but it's not recommended.






share|improve this answer













yes hi,
This is an easy trick, common and used everywhere in those programs and debuggers. You just set a counter for each type of braces, add 1 when it's '{' and substract one on the opposite direction. Line you won't get, but approximate solution will work once you reach out negative values, you should always get 0 in the end and never have negatives. If you want line anyway, just only empty spaces. Count empty spaces and work out your braces counting along with that, but it's not recommended.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 1 at 20:38









Vitali PomanitskiVitali Pomanitski

276




276













  • can you give me example

    – rizla
    Jan 1 at 20:48











  • Let it one and half year from now, I believe it is not slightly the time for you. I can describe the solution as I said in one sentence, but the code is usually not one sentence at all.

    – Vitali Pomanitski
    Jan 1 at 21:52



















  • can you give me example

    – rizla
    Jan 1 at 20:48











  • Let it one and half year from now, I believe it is not slightly the time for you. I can describe the solution as I said in one sentence, but the code is usually not one sentence at all.

    – Vitali Pomanitski
    Jan 1 at 21:52

















can you give me example

– rizla
Jan 1 at 20:48





can you give me example

– rizla
Jan 1 at 20:48













Let it one and half year from now, I believe it is not slightly the time for you. I can describe the solution as I said in one sentence, but the code is usually not one sentence at all.

– Vitali Pomanitski
Jan 1 at 21:52





Let it one and half year from now, I believe it is not slightly the time for you. I can describe the solution as I said in one sentence, but the code is usually not one sentence at all.

– Vitali Pomanitski
Jan 1 at 21:52




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53998739%2fhow-to-find-which-line-is-missing%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith