|
-
Oct 5th, 2007, 11:20 PM
#1
Thread Starter
New Member
Random and MethodNext
I am new to coding and I some advice with coding a math equation (multiplaction)using RandomObject.Next
This my statements:
Module MathQuiz
Sub Main()
'create random Mathequation
Dim randomObject As New Random()
Dim randomNumber As Integer = randomObject.Next() 'generate random number
Dim j As Integer
Dim k As Integer
'generate 20 random numbers between 1 and 15
For j As Integer = 1 To 15
Next
Console.Write()
For k As Integer = 1 To 15
Console.Write("randomObject.Next, k = 7")
If j And k Mod 15 = 0 Then
Console.WriteLine()
Console.ReadLine()
End If
Next
End Sub
End Module 'MathQuiz
-
Oct 6th, 2007, 02:51 AM
#2
Re: Random and MethodNext
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 
-
Oct 24th, 2007, 02:24 AM
#3
Re: Random and MethodNext
 Originally Posted by electro53
I am new to coding and I some advice with coding a math equation (multiplaction)using RandomObject.Next ...
There's no question here... could you be more specific?
The time you enjoy wasting is not wasted time.
Bertrand Russell
<- Remember to rate posts you find helpful.
-
Oct 24th, 2007, 02:57 AM
#4
Lively Member
Re: Random and MethodNext
Hi,
Don't know what you are doing, but for the part you want to generate 20 random numbers between 1 and 15
try this
Code:
For j As Integer = 1 To 20
Console.Write(randomObject.Next(1,15+1))
' Public Overridable Function [Next](ByVal minValue As Integer, ByVal maxValue As Integer) As Integer
' returns greater than or equal to minValue and less than maxValue
' the range of return values includes MinValue but not MaxValue.
' that's why (15+1), NOT 15
Next
-
Nov 1st, 2007, 11:36 AM
#5
Re: Random and MethodNext
Seems easier to do in VB6. Build a form with a listbox to hold the numbers:
Code:
Private Sub Form_Load()
Randomize
For I = 1 To 20
List1.AddItem Str$(Int(Rnd * 15) + 1)
Next
End Sub
-
Nov 1st, 2007, 02:22 PM
#6
Re: Random and MethodNext
20 random numbers between 1 and 15 would generate some dups.
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 
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
|