jhylands

Computer program

Oct 27th, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 5.27 KB | None | 0 0
  1. <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
  2. Partial Class Table_generator
  3.     Inherits System.Windows.Forms.Form
  4.  
  5.     'Form overrides dispose to clean up the component list.
  6.     <System.Diagnostics.DebuggerNonUserCode()> _
  7.     Protected Overrides Sub Dispose(ByVal disposing As Boolean)
  8.         Try
  9.             If disposing AndAlso components IsNot Nothing Then
  10.                 components.Dispose()
  11.             End If
  12.         Finally
  13.             MyBase.Dispose(disposing)
  14.         End Try
  15.     End Sub
  16.  
  17.     'Required by the Windows Form Designer
  18.     Private components As System.ComponentModel.IContainer
  19.  
  20.     'NOTE: The following procedure is required by the Windows Form Designer
  21.     'It can be modified using the Windows Form Designer.  
  22.     'Do not modify it using the code editor.
  23.     <System.Diagnostics.DebuggerStepThrough()> _
  24.     Private Sub InitializeComponent()
  25.         Me.components = New System.ComponentModel.Container()
  26.         Me.generate = New System.Windows.Forms.Button()
  27.         Me.WebBrowser1 = New System.Windows.Forms.WebBrowser()
  28.         Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
  29.         Me.SuspendLayout()
  30.         '
  31.         'generate
  32.         '
  33.         Me.generate.Location = New System.Drawing.Point(0, 0)
  34.         Me.generate.Name = "generate"
  35.         Me.generate.Size = New System.Drawing.Size(99, 23)
  36.         Me.generate.TabIndex = 0
  37.         Me.generate.Text = "Generate table"
  38.         Me.generate.UseVisualStyleBackColor = True
  39.         '
  40.         'WebBrowser1
  41.         '
  42.         Me.WebBrowser1.Location = New System.Drawing.Point(0, 29)
  43.         Me.WebBrowser1.MinimumSize = New System.Drawing.Size(20, 20)
  44.         Me.WebBrowser1.Name = "WebBrowser1"
  45.         Me.WebBrowser1.Size = New System.Drawing.Size(723, 419)
  46.         Me.WebBrowser1.TabIndex = 1
  47.         '
  48.         'Timer1
  49.         '
  50.         Me.Timer1.Enabled = True
  51.         Me.Timer1.Interval = 900
  52.         '
  53.         'Table_generator
  54.         '
  55.         Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
  56.         Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
  57.         Me.ClientSize = New System.Drawing.Size(972, 444)
  58.         Me.Controls.Add(Me.WebBrowser1)
  59.         Me.Controls.Add(Me.generate)
  60.         Me.Name = "Table_generator"
  61.         Me.Text = "Multiplication table generator"
  62.         Me.ResumeLayout(False)
  63.  
  64.     End Sub
  65.     Friend WithEvents generate As System.Windows.Forms.Button
  66.     Friend WithEvents WebBrowser1 As System.Windows.Forms.WebBrowser
  67.     Friend WithEvents Timer1 As System.Windows.Forms.Timer
  68.  
  69. End Class
  70. Public Class Table_generator
  71.     Private Sub generate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles generate.Click
  72.         'Define size as integer : this is the size of the table
  73.         Dim size As Integer = 1
  74.         'Retive what the User wants as the size of the table
  75. Tryagain:
  76.         Try
  77.             Dim input = InputBox("what size do you want the multiplication table to be? (Please enter a posative whole number)")
  78.             'check if the person wants to exit this sub
  79.             If input = "" Then
  80.                 Exit Sub
  81.             Else
  82.                 size = input
  83.             End If
  84.             If size < 1 Then
  85.                 MsgBox("please enter a posative whole number!")
  86.                 GoTo tryagain
  87.             End If
  88.         Catch
  89.             MsgBox("error please enter a posative whole number!")
  90.             GoTo tryagain
  91.         End Try
  92.         'Tell the user the the table is being prossesed and that large tables may take some time
  93.         WebBrowser1.DocumentText = "<h1>Generating table</h1> <p> The program is now generating your multiplication table of " & size & " by " & size & " bare in mind that large tables may cause the program to crash piriodicaly.</p>"
  94.         Me.Refresh()
  95.         'Generate an array that contains the table
  96.         Dim table(size, size) As Integer
  97.         'Fill the table here the 0 array entries are blank because they are used after
  98.         For I = 1 To size
  99.             For n = 1 To size
  100.                 table(I, n) = I * n
  101.             Next
  102.         Next
  103.         'Use the empty cells for the edge of the table
  104.         table(0, 0) = 0
  105.         For I = 1 To size
  106.             table(0, I) = I
  107.             table(I, 0) = I
  108.         Next
  109.         MsgBox("Warning!" & Chr(13) & "The following part of the program may take some time to compleat!")
  110.         'send the array away to be made and then print what comes back onto the screen
  111.         WebBrowser1.DocumentText() = Formathtmltable(table)
  112.     End Sub
  113.     Function Formathtmltable(ByVal table)
  114.         'Create a variable for the source code and start the code
  115.         Dim source As String = "<html><head><style>td{text-align:right;}</style></head><body><table border=""1"">"
  116.         Dim size As Int16 = table.getlength(0) - 1
  117.         For I = 0 To size 'for each row
  118.             source = source & "<tr>"
  119.             For n = 0 To size ' for each collonn
  120.                 source = source & "<td>" & table(I, n) & "</td>"
  121.             Next
  122.             source = source & "</tr>"
  123.         Next
  124.         source = source & "</table></body></ html>"
  125.         Return source
  126.     End Function
  127.  
  128.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  129.         WebBrowser1.Width = Me.Width - 50
  130.         WebBrowser1.Height = Me.Height - 100
  131.     End Sub
  132. End Class
Advertisement
Add Comment
Please, Sign In to add comment