|
-
Sep 23rd, 2004, 09:08 PM
#1
Thread Starter
New Member
random 4 letters with condition
i dont knw were to put this i hope some one can help me.. i need a code for this:
i am to create a program that generates 4 random letters.
conditions : a letter must not repeate twice
: there must always be a vowel
Pls help.. i knw this is easy,, i just cant find a code.. thanx..
-
Sep 25th, 2004, 01:10 PM
#2
Welcome to the Forums.
Do you mean four letters as in documents or letters as in four
characters (a, b, c, d)?
Can you show us a smaple of what you need?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 26th, 2004, 11:10 PM
#3
Thread Starter
New Member
here is the example
the program generates 4 letters that has a vowel
ex. asdf
lkji
as long as there is a vowel and no letter is repeated tiwce..
-
Sep 27th, 2004, 10:44 AM
#4
Junior Member
Hi,
may be this code will help you:
VB Code:
Function FourLetters() As String
Dim cnt As Integer
Dim myCharStr As String
Dim newChr As String
Randomize
Do Until vowelIn(myCharStr)
myCharStr = RandomCharacter
For cnt = 2 To 4
Do
newChr = RandomCharacter
Loop Until InStr(myCharStr, newChr) = 0
myCharStr = myCharStr & newChr
Next cnt
Loop
FourLetters = myCharStr
End Function
Private Function RandomCharacter() As String
RandomCharacter = Chr(Asc("a") + Rnd * 26)
End Function
Private Function vowelIn(myCharStr) As Boolean
Dim i As Integer
vowelIn = (InStr(myCharStr, "a") > 0) Or _
(InStr(myCharStr, "e") > 0) Or _
(InStr(myCharStr, "i") > 0) Or _
(InStr(myCharStr, "o") > 0) Or _
(InStr(myCharStr, "u") > 0)
End Function
Last edited by zeneri; Sep 27th, 2004 at 11:21 AM.
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
|