473,321 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

An unhandled exception of type 'System.StackOverflowException' occurred in System.Win

How do you resolve this problem in VB.NET? Press F1 to run the program. The dictionary can be found here:

https://docs.google.com/document/d/1...it?usp=sharing

Here is the code:

Expand|Select|Wrap|Line Numbers
  1. Imports System.IO
  2. Imports System
  3. Imports System.Collections.Generic
  4. Public Class Form1
  5.     Friend WithEvents RichTextBox1 As New RichTextBox With {.Dock = DockStyle.Fill}
  6.     Friend WithEvents ReplaceMenu As New ContextMenuStrip
  7.     Dim kamau As String
  8.     Dim foundIndex As Integer
  9.     Dim checkWord As String
  10.     Dim replacementWords As List(Of String)()
  11.     Private replacements As New Dictionary(Of String, List(Of String))
  12.  
  13.  
  14.     Private nextCheckIndex As Integer
  15.  
  16.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  17.         Controls.Add(RichTextBox1)
  18.  
  19.  
  20.         Using reader As New StreamReader("C:\Users\Acer\Desktop\Text Files\output10.txt")
  21.             Do Until reader.EndOfStream
  22.                 Dim parts = reader.ReadLine().Split("|"c)
  23.  
  24.                 If replacements.ContainsKey(parts(0)) Then
  25.                     replacements(parts(0)).Add(parts(1))
  26.                 Else
  27.                     Dim newWordList As New List(Of String)
  28.                     newWordList.Add(parts(1))
  29.                     replacements.Add(parts(0), newWordList)
  30.                 End If
  31.  
  32.  
  33.             Loop
  34.         End Using
  35.  
  36.  
  37.  
  38.  
  39.         RichTextBox1.Text = "You gave a bad advice, irregardless of your intention. You provided a bad advice, irregardless of your intention. "
  40.     End Sub
  41.  
  42.     Private Sub RichTextBox1_KeyUp(sender As Object, e As KeyEventArgs) Handles RichTextBox1.KeyUp
  43.         If e.KeyCode = Keys.F1 Then
  44.             nextCheckIndex = 0
  45.             CheckForReplacementText()
  46.         End If
  47.     End Sub
  48.  
  49.     Public Sub CheckForReplacementText()
  50.  
  51.         If nextCheckIndex = replacements.Count Then
  52.  
  53.             MessageBox.Show("Check complete.")
  54.         Else
  55.  
  56.             checkWord = replacements.Keys.ElementAt(nextCheckIndex)
  57.  
  58.             foundIndex = RichTextBox1.Find(checkWord, 0, RichTextBox1.TextLength, RichTextBoxFinds.WholeWord)
  59.  
  60.  
  61.         If foundIndex > -1 Then
  62.  
  63.             ReplaceMenu.Items.Clear()
  64.  
  65.             For Each replacement In replacements(checkWord)
  66.                  ReplaceMenu.Items.Add(replacement, Nothing, Sub(sndr As Object, ea As EventArgs)
  67.                                                                      RichTextBox1.SelectedText = kamau
  68.                                                                      CheckForReplacementText()
  69.                                                                  End Sub)
  70.  
  71.  
  72.             Next
  73.             ReplaceMenu.Show(RichTextBox1, RichTextBox1.GetPositionFromCharIndex(RichTextBox1.SelectionStart + RichTextBox1.SelectionLength))
  74.         Else
  75.             nextCheckIndex += 1
  76.             CheckForReplacementText()
  77.         End If
  78.  
  79.         End If
  80.  
  81.     End Sub
  82.  
  83.     Public Sub ReplaceMenu_ItemClicked(ByVal sender As Object, ByVal e As ToolStripItemClickedEventArgs) Handles ReplaceMenu.ItemClicked
  84.  
  85.         Dim checkWord = replacements.Keys.ElementAt(nextCheckIndex)
  86.  
  87.         For Each replacement In replacements(checkWord)
  88.  
  89.             replacement = e.ClickedItem.Text
  90.             kamau = replacement
  91.  
  92.         Next
  93.     End Sub
  94.  
  95.  
  96. End Class
  97.  
Dec 17 '15 #1
0 1094

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lee Holsenbeck | last post by:
Hi, I get this error in a vb.net windows application in the .exe: "An unhandled exception of type 'System.argumentException' occurred in system.drawing.dll" This occurs only on 1 user's pc,...
1
by: Merlynx | last post by:
i am getting that error with the Event() method. Don't know whether if i have used the CreateEvent function well as it is the 1st time i used it moreover i am net to C#. If anyone can point me out...
3
by: karunakar | last post by:
Hi All Here iam getting this Error "Specified cast is not valid." My Project has Onc solution diffrent class libarary In that solution DALfactory solution iam getting this error I was calling...
3
by: Pieter | last post by:
Hi, I have a Windows Forms application (VB.NET 2.0) which uses a Class Library in C#. The application runs fine, but when I run it in debug mode, I get several "A first chance exception of type...
1
by: Savas Ates | last post by:
I want to change my controls in my class I have the following code. All the code in my _default page class How can i solve it ? public class antu:_default {
3
by: GS | last post by:
why am i getting A first chance exception of type 'System.NullReferenceException' occurred in myapp.exe below? and what can i do get rid of it? Private Function getPrefxType() As String If...
2
by: purnimakarnati | last post by:
When I added a textbox and assigned the value to the textbox and added to htmltablecell while debugging I am able to see the correct assigned value but if I see the contents in the HTMLTABLE in...
0
by: Elmo Watson | last post by:
I have a class - I Dim a SQLconnection, then, in Sub New, I instantiate it, so that it's available to me whenever I reference the class (correct?): Conn = New SqlConnection(msConn) Then, in my...
7
by: j4richard | last post by:
Help please, I am getting this "Unhandled Exception has occurred in your application" " A Generic error occurred in GDI+" See the end of this message for details on...
0
by: dawiisss | last post by:
Can someone help me I am building a browser in VB on webkit and gecko and every time I run it thats the error and after it the biuld when I run it shows me errors and then it turns multiply on and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.