Loop with a random
I made a little picker, it just says yes or not, but idk why it stucks in a loop i the While
Here is it:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim kk As Integer
kk = CInt(Int(Rnd() * 100) + 1)
While (kk <> 0 Or kk <> 1)
kk = kk / 2
End While
lblSiNo.Text = kk.ToString
End Sub
If it's 1
, is a Yes, if it's 0
, is No
infinite-loop
add a comment |
I made a little picker, it just says yes or not, but idk why it stucks in a loop i the While
Here is it:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim kk As Integer
kk = CInt(Int(Rnd() * 100) + 1)
While (kk <> 0 Or kk <> 1)
kk = kk / 2
End While
lblSiNo.Text = kk.ToString
End Sub
If it's 1
, is a Yes, if it's 0
, is No
infinite-loop
add a comment |
I made a little picker, it just says yes or not, but idk why it stucks in a loop i the While
Here is it:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim kk As Integer
kk = CInt(Int(Rnd() * 100) + 1)
While (kk <> 0 Or kk <> 1)
kk = kk / 2
End While
lblSiNo.Text = kk.ToString
End Sub
If it's 1
, is a Yes, if it's 0
, is No
infinite-loop
I made a little picker, it just says yes or not, but idk why it stucks in a loop i the While
Here is it:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim kk As Integer
kk = CInt(Int(Rnd() * 100) + 1)
While (kk <> 0 Or kk <> 1)
kk = kk / 2
End While
lblSiNo.Text = kk.ToString
End Sub
If it's 1
, is a Yes, if it's 0
, is No
infinite-loop
infinite-loop
asked Dec 28 '18 at 0:47
Aaron Herrera
81
81
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
While (kk <> 0 Or kk <> 1)
Every integer is different from 0 or 1, it can't be both equals to 1 and 0. Your predicate is always true.
So thekk = kk/2
is doing nothing there?
– Aaron Herrera
Dec 28 '18 at 0:58
Your loop means "while kk is not 0 and 1 at the same time, divide kk by 2". This is a logical impossibility.
– Calimero
Dec 28 '18 at 1:04
Theres an Or, so how can i put an OR there?
– Aaron Herrera
Dec 28 '18 at 1:10
I have no idea what language you used, because you didn't tell us in your post, but usually <> means different. Try to replace it with the symbol for logical equality of this specific language if you want to stop your loop when kk equals 0 or 1 (also, kk is an integer and kk/2 may not be equal to a integer. I assume you are aware of this and know the consequence).
– Calimero
Dec 28 '18 at 1:14
Is Visual Basic
– Aaron Herrera
Dec 28 '18 at 1:15
|
show 6 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53952481%2floop-with-a-random%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
While (kk <> 0 Or kk <> 1)
Every integer is different from 0 or 1, it can't be both equals to 1 and 0. Your predicate is always true.
So thekk = kk/2
is doing nothing there?
– Aaron Herrera
Dec 28 '18 at 0:58
Your loop means "while kk is not 0 and 1 at the same time, divide kk by 2". This is a logical impossibility.
– Calimero
Dec 28 '18 at 1:04
Theres an Or, so how can i put an OR there?
– Aaron Herrera
Dec 28 '18 at 1:10
I have no idea what language you used, because you didn't tell us in your post, but usually <> means different. Try to replace it with the symbol for logical equality of this specific language if you want to stop your loop when kk equals 0 or 1 (also, kk is an integer and kk/2 may not be equal to a integer. I assume you are aware of this and know the consequence).
– Calimero
Dec 28 '18 at 1:14
Is Visual Basic
– Aaron Herrera
Dec 28 '18 at 1:15
|
show 6 more comments
While (kk <> 0 Or kk <> 1)
Every integer is different from 0 or 1, it can't be both equals to 1 and 0. Your predicate is always true.
So thekk = kk/2
is doing nothing there?
– Aaron Herrera
Dec 28 '18 at 0:58
Your loop means "while kk is not 0 and 1 at the same time, divide kk by 2". This is a logical impossibility.
– Calimero
Dec 28 '18 at 1:04
Theres an Or, so how can i put an OR there?
– Aaron Herrera
Dec 28 '18 at 1:10
I have no idea what language you used, because you didn't tell us in your post, but usually <> means different. Try to replace it with the symbol for logical equality of this specific language if you want to stop your loop when kk equals 0 or 1 (also, kk is an integer and kk/2 may not be equal to a integer. I assume you are aware of this and know the consequence).
– Calimero
Dec 28 '18 at 1:14
Is Visual Basic
– Aaron Herrera
Dec 28 '18 at 1:15
|
show 6 more comments
While (kk <> 0 Or kk <> 1)
Every integer is different from 0 or 1, it can't be both equals to 1 and 0. Your predicate is always true.
While (kk <> 0 Or kk <> 1)
Every integer is different from 0 or 1, it can't be both equals to 1 and 0. Your predicate is always true.
edited Dec 28 '18 at 2:23
answered Dec 28 '18 at 0:53
Calimero
516
516
So thekk = kk/2
is doing nothing there?
– Aaron Herrera
Dec 28 '18 at 0:58
Your loop means "while kk is not 0 and 1 at the same time, divide kk by 2". This is a logical impossibility.
– Calimero
Dec 28 '18 at 1:04
Theres an Or, so how can i put an OR there?
– Aaron Herrera
Dec 28 '18 at 1:10
I have no idea what language you used, because you didn't tell us in your post, but usually <> means different. Try to replace it with the symbol for logical equality of this specific language if you want to stop your loop when kk equals 0 or 1 (also, kk is an integer and kk/2 may not be equal to a integer. I assume you are aware of this and know the consequence).
– Calimero
Dec 28 '18 at 1:14
Is Visual Basic
– Aaron Herrera
Dec 28 '18 at 1:15
|
show 6 more comments
So thekk = kk/2
is doing nothing there?
– Aaron Herrera
Dec 28 '18 at 0:58
Your loop means "while kk is not 0 and 1 at the same time, divide kk by 2". This is a logical impossibility.
– Calimero
Dec 28 '18 at 1:04
Theres an Or, so how can i put an OR there?
– Aaron Herrera
Dec 28 '18 at 1:10
I have no idea what language you used, because you didn't tell us in your post, but usually <> means different. Try to replace it with the symbol for logical equality of this specific language if you want to stop your loop when kk equals 0 or 1 (also, kk is an integer and kk/2 may not be equal to a integer. I assume you are aware of this and know the consequence).
– Calimero
Dec 28 '18 at 1:14
Is Visual Basic
– Aaron Herrera
Dec 28 '18 at 1:15
So the
kk = kk/2
is doing nothing there?– Aaron Herrera
Dec 28 '18 at 0:58
So the
kk = kk/2
is doing nothing there?– Aaron Herrera
Dec 28 '18 at 0:58
Your loop means "while kk is not 0 and 1 at the same time, divide kk by 2". This is a logical impossibility.
– Calimero
Dec 28 '18 at 1:04
Your loop means "while kk is not 0 and 1 at the same time, divide kk by 2". This is a logical impossibility.
– Calimero
Dec 28 '18 at 1:04
Theres an Or, so how can i put an OR there?
– Aaron Herrera
Dec 28 '18 at 1:10
Theres an Or, so how can i put an OR there?
– Aaron Herrera
Dec 28 '18 at 1:10
I have no idea what language you used, because you didn't tell us in your post, but usually <> means different. Try to replace it with the symbol for logical equality of this specific language if you want to stop your loop when kk equals 0 or 1 (also, kk is an integer and kk/2 may not be equal to a integer. I assume you are aware of this and know the consequence).
– Calimero
Dec 28 '18 at 1:14
I have no idea what language you used, because you didn't tell us in your post, but usually <> means different. Try to replace it with the symbol for logical equality of this specific language if you want to stop your loop when kk equals 0 or 1 (also, kk is an integer and kk/2 may not be equal to a integer. I assume you are aware of this and know the consequence).
– Calimero
Dec 28 '18 at 1:14
Is Visual Basic
– Aaron Herrera
Dec 28 '18 at 1:15
Is Visual Basic
– Aaron Herrera
Dec 28 '18 at 1:15
|
show 6 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53952481%2floop-with-a-random%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown