how to find which line is missing “{” “}”
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
add a comment |
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
Please learn about the Stack data structure. This is a classic problem solved by stacks.
– Yakov Dan
Jan 1 at 21:30
add a comment |
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
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
basic
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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.
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Please learn about the Stack data structure. This is a classic problem solved by stacks.
– Yakov Dan
Jan 1 at 21:30