Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 5th, 2006, 5:58 PM   #1
dwizzle13
Newbie
 
Join Date: Oct 2006
Posts: 19
Rep Power: 0 dwizzle13 is on a distinguished road
Question 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
dwizzle13 is offline   Reply With Quote
Old Dec 6th, 2006, 6:51 AM   #2
BlackDal
Newbie
 
Join Date: Feb 2006
Posts: 12
Rep Power: 0 BlackDal is on a distinguished road
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
BlackDal is offline   Reply With Quote
Old Dec 6th, 2006, 12:09 PM   #3
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 810
Rep Power: 4 The Dark is on a distinguished road
Quote:
Originally Posted by BlackDal View Post
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.
The Dark is offline   Reply With Quote
Old Dec 7th, 2006, 4:47 AM   #4
BlackDal
Newbie
 
Join Date: Feb 2006
Posts: 12
Rep Power: 0 BlackDal is on a distinguished road
yes
its a typing error.
BlackDal is offline   Reply With Quote
Old Dec 7th, 2006, 5:58 PM   #5
dwizzle13
Newbie
 
Join Date: Oct 2006
Posts: 19
Rep Power: 0 dwizzle13 is on a distinguished road
I figured it out, I made a mistake, and didn't make the if's both = something.
dwizzle13 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Another CSS Issue Lich HTML / XHTML / CSS 3 Jun 29th, 2006 3:04 PM
Boolean operators?????? SpaderS C++ 4 Mar 20th, 2006 8:24 PM
Weirdness of -l compile flag kurt C 8 Nov 16th, 2005 12:44 AM
DOM (createElement issue...) tempest JavaScript and Client-Side Browser Scripting 2 Nov 1st, 2005 6:50 PM
JNDI and LDAP issue Mortavitch Java 5 Oct 20th, 2005 11:10 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:25 AM.

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