| | |
If any of item in Array
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Aug 2008
Posts: 4
Reputation:
Solved Threads: 0
Dim Friends(0 To 10) As String Private Sub Command1_Click() If Friends(any) = text1.text Then '(what should I put here instead of any?) MsgBox "You already have " & text1.text " in the list else end if End Sub
In above code
I have an empty array of 10 friends
I have a button,
on pressing it I can add a new friend in any array
I want such a code:
While adding a new friend, it should prompt if the friend is already available in array.
Please Help!
•
•
Join Date: Mar 2009
Posts: 865
Reputation:
Solved Threads: 157
You will need a variable to keep track of how many friends have been entered.
Then you will need to initialize your friend counter
Then you will need to test to see if you haved entered any friends yet...
But if they have then you need to test if you have reached the limit...
Then of course if you have not exceeded the friend count...
Good Luck
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim MyFriendCount As Integer, LoopCounter As Integer
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
MyFriendCount = -1
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim FoundFriend As Boolean If MyFriendCount = -1 Then 'no friend have been entered
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
ElseIf MyFriendCount > 10 Then 'too many friends or you need to redimension array so notify user...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Else 'need to check to see if you have already entered friend For LoopCounter = 0 To MyFriendCount If UCase(Text1.Text) = UCase(Friends(LoopCount)) Then FoundFriend = True Else FoundFriend = False End If Next LoopCount If FoundFriend = True Then 'notify user Else MyFriendCount = MyFriendCount + 1 Friends(MyFriendCount) = Text1.Text End If End If
Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.
Thanks
Thanks
![]() |
Similar Threads
- remove item in array (C++)
- Using recursion to find largest item in an array (C++)
- Delete an item from an array (C)
- array of structures within a struct (C++)
- need Help in store Datagrid item in an array (VB.NET)
- Stripping the last element off an array (Perl)
- Array cell contains the memory address of the next cell ???? (C)
- how to set up my for loop to print my array in reverse (Java)
- Array problem (C)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: SQL command and vb6
- Next Thread: Auto Increent Value and Then Save it.
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





