|
-
Aug 11th, 2012, 03:27 PM
#1
Thread Starter
Addicted Member
What is wrong with my if statement?
I feel kind of silly asking about an if statement but I am having an issue.
I created a goto line form in my application and it works, I am just trying to set some perimeters so it prompts a messagebox stating that the line number they entered doesn't exist. Basically if the number is lower than 1 or higher then the line count. Here is the code, when I have if statements nested like that the error will only work for whichever is first(this case it is the less than 1). I need it to work for both.
vb Code:
Dim page As RadPageViewPage = AutoGamerMain.RadPageView1.SelectedPage
For Each txt As FastColoredTextBox In page.Controls.OfType(Of FastColoredTextBox)()
If LineNumberTxt.Text <= txt.LinesCount Then
If LineNumberTxt.Text >= 1 Then
txt.Focus()
txt.Selection.Start = New Place(0, LineNumberTxt.Text - 1)
txt.DoSelectionVisible()
txt.Invalidate()
Else
MessageBox.Show("You have entered a line which does not exist. Perimeters are (1-" & txt.LinesCount & "). Please choose a new line.")
End If
End If
Next
-
Aug 11th, 2012, 04:13 PM
#2
Re: What is wrong with my if statement?
if the number is lower than 1 or higher then the line count
Seriously?
-
Aug 11th, 2012, 04:22 PM
#3
Thread Starter
Addicted Member
Re: What is wrong with my if statement?
 Originally Posted by dunfiddlin
Seriously?
Worded wrong. I'll change it around. It should work like this though? It needs to be both less than the lins count an higher or equal to 1.
-
Aug 11th, 2012, 04:28 PM
#4
Thread Starter
Addicted Member
Re: What is wrong with my if statement?
Blame it on a long day.
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim page As RadPageViewPage = AutoGamerMain.RadPageView1.SelectedPage
For Each txt As FastColoredTextBox In page.Controls.OfType(Of FastColoredTextBox)()
If LineNumberTxt.Text >= txt.LinesCount Or LineNumberTxt.Text <= 1 Then
MessageBox.Show("You have entered a line which does not exist. Perimeters are (1-" & txt.LinesCount & "). Please choose a new line.")
Else
txt.Focus()
txt.Selection.Start = New Place(0, LineNumberTxt.Text - 1)
txt.DoSelectionVisible()
txt.Invalidate()
End If
Next
End Sub
-
Aug 11th, 2012, 04:29 PM
#5
Re: What is wrong with my if statement?
If ln >= 1 AndAlso ln <= count 'the other way round
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|