Guest User

Untitled

a guest
May 9th, 2012
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.51 KB | None | 0 0
  1. Public Class Form1
  2.  
  3.     Const FILENAME As String = "c:\Windows\Temp\sudoku.txt"
  4.     Const SUDOKU_COLS As Integer = 9
  5.     Const SUDOKU_ROWS As Integer = 9
  6.     Dim sudoku(SUDOKU_ROWS, SUDOKU_COLS) As TextBox
  7.  
  8.  
  9.     Private Sub cmdFileReader_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFileReader.Click
  10.         Dim textfromfile As String
  11.         textfromfile = My.Computer.FileSystem.ReadAllText(FILENAME)
  12.         'MsgBox(sudokugrid)
  13.         Dim lines() As String = Split(textfromfile, vbCrLf)
  14.         Dim y As Integer, x As Integer
  15.         Dim t As String
  16.         For y = 0 To SUDOKU_ROWS - 1
  17.             'MsgBox(lines(y))
  18.             For x = 0 To SUDOKU_COLS - 1
  19.                 t = Mid(lines(y), x + 1, 1)
  20.                 'MsgBox("x=" & x & " valore: " & t)
  21.                 If t <> "0" Then
  22.                     sudoku(y, x).Text = t
  23.                     sudoku(y, x).Enabled = False
  24.                 End If
  25.             Next
  26.         Next
  27.         cmdFileReader.Enabled = False
  28.  
  29.     End Sub
  30.  
  31.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  32.         Dim x As Integer, y As Integer
  33.         For y = 0 To SUDOKU_ROWS - 1
  34.             For x = 0 To SUDOKU_COLS - 1
  35.                 sudoku(y, x) = New TextBox
  36.                 sudoku(y, x).Parent = Me
  37.                 sudoku(y, x).Top = 60 + y * 30
  38.                 sudoku(y, x).Left = 20 + x * 30
  39.                 sudoku(y, x).Width = 20
  40.             Next
  41.         Next
  42.  
  43.     End Sub
  44. End Class
Advertisement
Add Comment
Please, Sign In to add comment