I want to assign a value
But did not give specific refers to the first
Only qualified
Only one of their values is 1
Everything else is 0
How to do?
(PS: they are at the same time, not the if one took 1, then everything else is 0, there is no order, to ensure a 1 at the same time, N - 1 0)
CodePudding user response:
Arr (10), there is only one element of the value is 1, 0, all the rest?Then do you still use an array? Directly with an integer said don't have to do is: if the number is a non-negative integer power of 2, said legal, if not in both cases, said it would be illegal,
CodePudding user response:
You define an array directly, and then they assign to a 1, isn't it just finished the rest of the 0.Is this your code, you have the final say.
CodePudding user response:
If in the array is a chance, you can use the vb random function, it is not good,A random out of the array, then the assignment for one, the other is zero
CodePudding user response:
Array can do this job, you must write their own codeCodePudding user response:
Use OptionButton controlsCodePudding user response:
This???????Dim arr (10) as string
For I=0 to ubound (arr)
If I=0 then
Arr (I)=1
The else
Arr (I)=0
End the if
I=I + 1
Next
CodePudding user response: