D
daniel l-s
Guest
Public Class form1
Class sudoku_textbox
Inherits TextBox
Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)
If Char.IsDigit(e.KeyChar) Or e.KeyChar = " " Or e.KeyChar = ControlChars.Back Then
e.Handled = False
Else
e.Handled = True
End If
If e.KeyChar = " " Or e.KeyChar = "0" Then
e.KeyChar = ControlChars.Back
End If
End Sub
End Class
Dim cell(0 To 8, 0 To 8) As sudoku_textbox
Dim grid(0 To 8, 0 To 8) As String
Dim backtracking As Boolean = False
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
label1.Text = "X= " & Control.MousePosition.X
Label2.Text = "Y= " & Control.MousePosition.Y
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyClass.Load
Dim xxtra As Integer
Dim yxtra As Integer
Me.CenterToParent()
Timer1.Start() 'start timer
Timer1.Interval = 10 'milisecond
For x As Integer = 0 To 8
For y As Integer = 0 To 8
cell(x, y) = New sudoku_textbox
cell(x, y).AutoSize = False
'this took me sooo long to figure out' ' this one line of code allows you to change the width and height without the height being set'
cell(x, y).Font = New Font("Roboto", 50.0, FontStyle.Regular)
' change font and font size of the text inside the cells '
cell(x, y).Text = ""
cell(x, y).Width = 90
cell(x, y).Height = 90
'change the width and height of the cells'
cell(x, y).MaxLength = 1
'allowing a maxium of 1 character inside each cell'
cell(x, y).TextAlign = HorizontalAlignment.Center
'allowing the text inside the cells to be centerized'
xxtra = 0
yxtra = 0
If x > 2 Then
xxtra = 4
End If
If x > 5 Then
xxtra = 8
End If
If y > 2 Then
yxtra = 4
End If
If y > 5 Then
yxtra = 8
End If
cell(x, y).Location = New Point(45 + x * 90 + xxtra, 120 + y * 90 + yxtra)
Me.Controls.Add(cell(x, y))
AddHandler cell(x, y).TextChanged, AddressOf cell_changed
Next
Next
End Sub
Continue reading...
Class sudoku_textbox
Inherits TextBox
Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)
If Char.IsDigit(e.KeyChar) Or e.KeyChar = " " Or e.KeyChar = ControlChars.Back Then
e.Handled = False
Else
e.Handled = True
End If
If e.KeyChar = " " Or e.KeyChar = "0" Then
e.KeyChar = ControlChars.Back
End If
End Sub
End Class
Dim cell(0 To 8, 0 To 8) As sudoku_textbox
Dim grid(0 To 8, 0 To 8) As String
Dim backtracking As Boolean = False
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
label1.Text = "X= " & Control.MousePosition.X
Label2.Text = "Y= " & Control.MousePosition.Y
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyClass.Load
Dim xxtra As Integer
Dim yxtra As Integer
Me.CenterToParent()
Timer1.Start() 'start timer
Timer1.Interval = 10 'milisecond
For x As Integer = 0 To 8
For y As Integer = 0 To 8
cell(x, y) = New sudoku_textbox
cell(x, y).AutoSize = False
'this took me sooo long to figure out' ' this one line of code allows you to change the width and height without the height being set'
cell(x, y).Font = New Font("Roboto", 50.0, FontStyle.Regular)
' change font and font size of the text inside the cells '
cell(x, y).Text = ""
cell(x, y).Width = 90
cell(x, y).Height = 90
'change the width and height of the cells'
cell(x, y).MaxLength = 1
'allowing a maxium of 1 character inside each cell'
cell(x, y).TextAlign = HorizontalAlignment.Center
'allowing the text inside the cells to be centerized'
xxtra = 0
yxtra = 0
If x > 2 Then
xxtra = 4
End If
If x > 5 Then
xxtra = 8
End If
If y > 2 Then
yxtra = 4
End If
If y > 5 Then
yxtra = 8
End If
cell(x, y).Location = New Point(45 + x * 90 + xxtra, 120 + y * 90 + yxtra)
Me.Controls.Add(cell(x, y))
AddHandler cell(x, y).TextChanged, AddressOf cell_changed
Next
Next
End Sub
Continue reading...