VB 2010阵列中的重复值 [英] Duplicate Values in an VB 2010 Arrays
问题描述
你好,
第一次发帖提问:
我想编写一个简单的代码数独游戏是4x4而不是9x9,因此它有4行4列,分为4个2x2部分。
我可以生成随机数,但我需要对其进行编码,以便行,列和部分中的数字不会重复。
各个图块的变量是Dim''d As Integer,并设置如下:
Dim int13A作为整数
设计为:int (行)(栏)(章节)所以int13A位于第1栏第3栏,
第A部分。
每个数组的代码都是这样,每个数组都有适当的名称:
Hello,
First time posting a question:
I am trying to code a simple Sudoku game that is 4x4 instead of the 9x9, such that it has 4 rows and 4 columns that are divided into 4 2x2 sections.
I can generate random numbers fine, but I need to code it so that no number in a row, column and section are duplicated.
The variable for the individual tiles is Dim''d As Integer, and set up as follows:
Dim int13A As Integer
The design is: int(Row)(Column)(Section) so "int13A" is located at Row 1, Column 3,
Section A.
My code for each array is this, with appropriate names for each:
Dim arrRow1(3) As Integer
arrRow1(0) = int11A
arrRow1(1) = int12A
arrRow1(2) = int13B
arrRow1(3) = int14B
Array.Sort(arrRow1)
If arrRow1(0) = 1 And arrRow1(1) = 2 And arrRow1(2) = 3 And arrRow1(3) = 4 Then
blnRow1 = True
Else
blnRow1 = False
End If
我有做 - 循环直到blnValidGrid = True 为每行1-4寻找True,然后每列1-4,然后每个块1-4;如果全部返回true,我得到blnValidGrid = True。如果没有,它会重新生成网格并尝试再次验证。
我遗漏某些地方因为它只是进入无限循环... :(
有任何想法吗?
谢谢,
Hank
I have a Do - Loop Until blnValidGrid = True that looks for True for each row 1-4, then each column 1-4 and then each block 1-4; if all return true, I get the blnValidGrid = True. If not, it regenerates the grid and attempts to validate again.
I am missing something somewhere cause it just goes into an infinite loop... :(
Any thoughts??
Thanks,
Hank
推荐答案
我会说实话,第一次使用这个,所以我不确定你的意思是哈希表...很新手,但是得到了每天都更好!
I''ll be honest, first time using this so I am not sure what you mean by "hashtable"... Pretty novice, but getting better every day!
hi HenryCasch
你可以为插入数据哈希表
hi HenryCasch
you can hashtable for insert data
这篇关于VB 2010阵列中的重复值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!