pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

pastebin private pastebin - collaborative debugging tool What's a private pastebin?

Posted by Ex on Sun 15th Aug 15:09
download | new post

  1. Public Class text_report_form
  2.     Const max_words As Integer = 150
  3.     Const max_characters As Integer = 1500
  4.  
  5.     Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click
  6.         Me.Close()
  7.     End Sub
  8.  
  9.     Private Sub create_report_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles create_report.Click
  10.         Dim input_text As String 'text from the top part of the form
  11.         Dim input_text_array() As Char 'array to store the characters in the input text
  12.  
  13.         Dim input_text_array_report_words As New ArrayList  'array for words and line numbers
  14.         Dim input_text_array_report_line_numbers As New ArrayList  'array for words and line numbers
  15.  
  16.         Dim arrays_dimensioned As Boolean = False   'check to see if array dimensioned
  17.  
  18.         Dim line_number As Integer 'variable to store line number of the current characters
  19.         Dim new_word As String 'variable to store the words made
  20.         Dim new_char As String 'variable to store the characters taken from the split text
  21.  
  22.         text_report.Text = "" 'clear the contents of the text box if it has anything in it
  23.  
  24.         input_text = text_before.Text 'set input text to text in the top text box field
  25.         input_text_array = input_text.ToCharArray 'split the input text into an array of characters
  26.  
  27.  
  28.  
  29.         'variables for searching
  30.         Dim found As Boolean 'for searching
  31.         Dim found_line As Boolean
  32.         Dim current_lines As Array 'store the line numbers when word already exists in the array
  33.         Dim index_found As Integer 'store the index of found word so that the line can be added
  34.  
  35.         'set line numbre to first line and new word to nothing
  36.         new_word = ""
  37.         line_number = "1"
  38.  
  39.         'for every character in the input_text_array
  40.  
  41.         For i = LBound(input_text_array) To UBound(input_text_array)
  42.  
  43.             new_char = input_text_array(i).ToString.ToLower
  44.  
  45.             ' MsgBox("lol" + Chr(13) + "lol")
  46.  
  47.             'If new_char = Chr(13).ToString Then 'BROKEN
  48.             ' MsgBox("NewLine")
  49.             ' End If
  50.  
  51.             'check to see whether the next character is a space , or . and if the new_words is not empty
  52.             If (new_char = " " Or new_char = "." Or new_char = "," Or i = UBound(input_text_array)) And new_word <> "" Then '
  53.  
  54.                 If new_char <> " " And new_char <> "." And new_char <> "," And new_char <> vbCrLf Then
  55.                     new_word += new_char
  56.                 ElseIf new_char.ToString = vbCrLf.ToString Then 'check to see if there is a new line BROKEN
  57.                     line_number = line_number + 1
  58.                 End If
  59.  
  60.  
  61.                 'add vaules to the array list
  62.                 'search array list for word
  63.                 Dim c As Integer = 0 'counter for while loop
  64.                 Dim al_words2 As System.Collections.IEnumerator = input_text_array_report_words.GetEnumerator()
  65.                 Dim al_line_numbers2 As System.Collections.IEnumerator = input_text_array_report_line_numbers.GetEnumerator()
  66.                 found = False
  67.                 found_line = False
  68.  
  69.                 While al_words2.MoveNext And al_line_numbers2.MoveNext And found = False
  70.                     If al_words2.Current.ToString = new_word Then
  71.                         found = True 'if found set found to true to stop the loop
  72.                         index_found = c 'set index
  73.  
  74.                         'search to see if word already exists on this line
  75.                         current_lines = Split(al_line_numbers2.Current, ",") 'break down line numbers into array
  76.                         For p = LBound(current_lines) To UBound(current_lines)
  77.                             If current_lines(p).ToString.Equals(line_number.ToString) And found_line = False Then
  78.                                 found_line = True 'if line is found set found_line to true to stop the loop
  79.                             End If
  80.                         Next p
  81.  
  82.                     End If
  83.                     c += 1
  84.                 End While
  85.  
  86.                 If found = True And found_line = False Then
  87.                     input_text_array_report_line_numbers.Item(index_found) = input_text_array_report_line_numbers.Item(index_found).ToString + "," + line_number
  88.                 ElseIf found = False Then
  89.                     input_text_array_report_words.Add(new_word)
  90.                     input_text_array_report_line_numbers.Add(line_number.ToString)
  91.                 End If
  92.  
  93.                 new_word = ""
  94.  
  95.             Else
  96.                 new_word += new_char
  97.             End If
  98.         Next i
  99.  
  100.         'create IEnumerator from array lists of words and line numbers to loop through for sorting
  101.         Dim al_words As System.Collections.IEnumerator = input_text_array_report_words.GetEnumerator()
  102.         Dim al_line_numbers As System.Collections.IEnumerator = input_text_array_report_line_numbers.GetEnumerator()
  103.  
  104.         'create new array to join both arrays
  105.         Dim sorted_array As New ArrayList
  106.  
  107.         'variables sorted array list
  108.         Dim split_array() As String 'to store the word and line numbers after the split
  109.         Dim output As String 'output for the words and line numbers for each word
  110.  
  111.         'combine both arrays into one
  112.         While al_words.MoveNext And al_line_numbers.MoveNext
  113.             sorted_array.Add(al_words.Current + "," + al_line_numbers.Current.ToString)
  114.         End While
  115.  
  116.         'sort new array list
  117.         sorted_array.Sort()
  118.  
  119.         'IEnumerator for sorted array list
  120.         Dim sorted_array_en As System.Collections.IEnumerator = sorted_array.GetEnumerator()
  121.  
  122.         While sorted_array_en.MoveNext
  123.             output = "" 'set output to nothing
  124.             split_array = Split(sorted_array_en.Current.ToString, ",") 'breakup line numbers into an array
  125.  
  126.             'for each line number add it to the line putput string
  127.             For i = LBound(split_array) To UBound(split_array)
  128.                 output += split_array(i).ToString + "     "
  129.             Next i
  130.  
  131.             'output word and its line numbers on the screen
  132.             text_report.Text += output + vbNewLine
  133.         End While
  134.  
  135.     End Sub
  136.  
  137.     Private Sub clear_text_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clear_text.Click
  138.         text_before.Text = ""
  139.     End Sub
  140.  
  141.     Private Sub clear_report_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clear_report.Click
  142.         text_report.Text = ""
  143.     End Sub
  144. End Class

Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Use syntax highlighting

To highlight particular lines, prefix each line with @@


Remember my settings