Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Const FILENAME As String = "c:\Windows\Temp\sudoku.txt"
- Const SUDOKU_COLS As Integer = 9
- Const SUDOKU_ROWS As Integer = 9
- Dim sudoku(SUDOKU_ROWS, SUDOKU_COLS) As TextBox
- Private Sub cmdFileReader_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFileReader.Click
- Dim textfromfile As String
- textfromfile = My.Computer.FileSystem.ReadAllText(FILENAME)
- 'MsgBox(sudokugrid)
- Dim lines() As String = Split(textfromfile, vbCrLf)
- Dim y As Integer, x As Integer
- Dim t As String
- For y = 0 To SUDOKU_ROWS - 1
- 'MsgBox(lines(y))
- For x = 0 To SUDOKU_COLS - 1
- t = Mid(lines(y), x + 1, 1)
- 'MsgBox("x=" & x & " valore: " & t)
- If t <> "0" Then
- sudoku(y, x).Text = t
- sudoku(y, x).Enabled = False
- End If
- Next
- Next
- cmdFileReader.Enabled = False
- End Sub
- Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- Dim x As Integer, y As Integer
- For y = 0 To SUDOKU_ROWS - 1
- For x = 0 To SUDOKU_COLS - 1
- sudoku(y, x) = New TextBox
- sudoku(y, x).Parent = Me
- sudoku(y, x).Top = 60 + y * 30
- sudoku(y, x).Left = 20 + x * 30
- sudoku(y, x).Width = 20
- Next
- Next
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment