Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
- Partial Class Table_generator
- Inherits System.Windows.Forms.Form
- 'Form overrides dispose to clean up the component list.
- <System.Diagnostics.DebuggerNonUserCode()> _
- Protected Overrides Sub Dispose(ByVal disposing As Boolean)
- Try
- If disposing AndAlso components IsNot Nothing Then
- components.Dispose()
- End If
- Finally
- MyBase.Dispose(disposing)
- End Try
- End Sub
- 'Required by the Windows Form Designer
- Private components As System.ComponentModel.IContainer
- 'NOTE: The following procedure is required by the Windows Form Designer
- 'It can be modified using the Windows Form Designer.
- 'Do not modify it using the code editor.
- <System.Diagnostics.DebuggerStepThrough()> _
- Private Sub InitializeComponent()
- Me.components = New System.ComponentModel.Container()
- Me.generate = New System.Windows.Forms.Button()
- Me.WebBrowser1 = New System.Windows.Forms.WebBrowser()
- Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
- Me.SuspendLayout()
- '
- 'generate
- '
- Me.generate.Location = New System.Drawing.Point(0, 0)
- Me.generate.Name = "generate"
- Me.generate.Size = New System.Drawing.Size(99, 23)
- Me.generate.TabIndex = 0
- Me.generate.Text = "Generate table"
- Me.generate.UseVisualStyleBackColor = True
- '
- 'WebBrowser1
- '
- Me.WebBrowser1.Location = New System.Drawing.Point(0, 29)
- Me.WebBrowser1.MinimumSize = New System.Drawing.Size(20, 20)
- Me.WebBrowser1.Name = "WebBrowser1"
- Me.WebBrowser1.Size = New System.Drawing.Size(723, 419)
- Me.WebBrowser1.TabIndex = 1
- '
- 'Timer1
- '
- Me.Timer1.Enabled = True
- Me.Timer1.Interval = 900
- '
- 'Table_generator
- '
- Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
- Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
- Me.ClientSize = New System.Drawing.Size(972, 444)
- Me.Controls.Add(Me.WebBrowser1)
- Me.Controls.Add(Me.generate)
- Me.Name = "Table_generator"
- Me.Text = "Multiplication table generator"
- Me.ResumeLayout(False)
- End Sub
- Friend WithEvents generate As System.Windows.Forms.Button
- Friend WithEvents WebBrowser1 As System.Windows.Forms.WebBrowser
- Friend WithEvents Timer1 As System.Windows.Forms.Timer
- End Class
- Public Class Table_generator
- Private Sub generate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles generate.Click
- 'Define size as integer : this is the size of the table
- Dim size As Integer = 1
- 'Retive what the User wants as the size of the table
- Tryagain:
- Try
- Dim input = InputBox("what size do you want the multiplication table to be? (Please enter a posative whole number)")
- 'check if the person wants to exit this sub
- If input = "" Then
- Exit Sub
- Else
- size = input
- End If
- If size < 1 Then
- MsgBox("please enter a posative whole number!")
- GoTo tryagain
- End If
- Catch
- MsgBox("error please enter a posative whole number!")
- GoTo tryagain
- End Try
- 'Tell the user the the table is being prossesed and that large tables may take some time
- 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>"
- Me.Refresh()
- 'Generate an array that contains the table
- Dim table(size, size) As Integer
- 'Fill the table here the 0 array entries are blank because they are used after
- For I = 1 To size
- For n = 1 To size
- table(I, n) = I * n
- Next
- Next
- 'Use the empty cells for the edge of the table
- table(0, 0) = 0
- For I = 1 To size
- table(0, I) = I
- table(I, 0) = I
- Next
- MsgBox("Warning!" & Chr(13) & "The following part of the program may take some time to compleat!")
- 'send the array away to be made and then print what comes back onto the screen
- WebBrowser1.DocumentText() = Formathtmltable(table)
- End Sub
- Function Formathtmltable(ByVal table)
- 'Create a variable for the source code and start the code
- Dim source As String = "<html><head><style>td{text-align:right;}</style></head><body><table border=""1"">"
- Dim size As Int16 = table.getlength(0) - 1
- For I = 0 To size 'for each row
- source = source & "<tr>"
- For n = 0 To size ' for each collonn
- source = source & "<td>" & table(I, n) & "</td>"
- Next
- source = source & "</tr>"
- Next
- source = source & "</table></body></ html>"
- Return source
- End Function
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- WebBrowser1.Width = Me.Width - 50
- WebBrowser1.Height = Me.Height - 100
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment