Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic .NET (http://www.programmingforums.org/forum19.html)
-   -   Boolean Flag issue (http://www.programmingforums.org/showthread.php?t=12116)

dwizzle13 Dec 5th, 2006 5:58 PM

Boolean Flag issue
 
Hi, I need to create a program to tell the position of the letters n and r in a word w/out using indexof, so I need to use word.substring, but for finding if the letter is in the word, I was thinking of using a variable, flag, as boolean to determine if a msgbox saying are you sure you want to continue would pop up, and I have not been able to get that part correct.

With my looking for both r and n process to say t or f for the flag, it thinks I'm converting n to boolean, but n is string. Is this how to do it, thx. Please help.

:

'look at flag
        Do While word.Substring(L, 1) <> "r"
            L = L + 1
            If word.Substring(L, 1) <> "r" And "n" Then
                flag = True
            End If
        Loop

        If flag = False Then
            z = MsgBox("the word has no r or n.  Quit? y/n", MsgBoxStyle.YesNo, "Quit?")
            If z = 6 Then
                Me.Close()
            End If
        End If


BlackDal Dec 6th, 2006 6:51 AM

try this...
:

        for L as integer = 1 to word.lenght
            If word.Substring(L, 1) <> "r" And word.Substring(L, 1) <> "r" <> "n" Then
                flag = True
            End If
        next

        If not flag Then
            z = MsgBox("the word has no r or n.  Quit? y/n", MsgBoxStyle.YesNo, "Quit?")
            If z = 6 Then
                Me.Close()
            End If
        End If


The Dark Dec 6th, 2006 12:09 PM

Quote:

Originally Posted by BlackDal (Post 120716)
try this...
:

        for L as integer = 1 to word.lenght
            If word.Substring(L, 1) <> "r" And word.Substring(L, 1) <> "r" <> "n" Then
                flag = True
            End If
        next

        If not flag Then
            z = MsgBox("the word has no r or n.  Quit? y/n", MsgBoxStyle.YesNo, "Quit?")
            If z = 6 Then
                Me.Close()
            End If
        End If


You might want to ignore that part in red.

BlackDal Dec 7th, 2006 4:47 AM

yes
its a typing error.

dwizzle13 Dec 7th, 2006 5:58 PM

I figured it out, I made a mistake, and didn't make the if's both = something.


All times are GMT -5. The time now is 3:01 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC