Two Variables - How To Get Random Value Between Them
Mar 12, 2012
I have 2 variables that I want to get a random value from in between their values... as of right now, for my working example, I have 2 stats... mindamage, and maxdamage, each being 30 and 60 respectively, well I am trying to get a random value between them, and then multiply it by a random number between 1 and 10 from after obtaining the random value between those two variables...
The code is as follows:
Public Sub agressive()
Dim agressiveattack As Integer
Dim MyRandomNumber As New Random(Now.Millisecond)
Dim x As Integer
x = MyRandomNumber.Next(CI.mindamage, CI.maxdamage)
agressiveattack = CI.strength * 1 + (10 / x)
MsgBox("Your agressive attack is " & agressiveattack & " points.")
End Sub
This is finally my first attempt at the beginning of my rpg's combat system... once I have a working adaptation of this code, I will be able to use it as the groundwork for my other three battle functions.
View 8 Replies
ADVERTISEMENT
Mar 25, 2012
i want to random 3 variables...
dim a as integer = 1
dim b as integer = 2
dim c as integer = 3
dim result as integer
result = random ( a , b , c)
How do i write the random stuff in visual basic.and how would i write something that Deletes the a from the random ( ); so im only left with random ( b , c ).
View 1 Replies
Nov 17, 2010
I'm tasked with the job of creating a javascript version of a units conversion application written in vb6. I have the source code but I don't have vb 6. The source code uses a dat file to hold a conversion array (unit type, unit, xfactor, plusfactor). Getting the data out of this file would be good to me. I tried creating a little app in vb 2010 to write the data from that dat file to a txt file using essentially the same code as the source code. And that has been somewhat successful (took a while to figure out the fixed string business). Now I can pull the data out as an array. The math elements of this array look fine but the strings are somewhat read-able but too garbled to use. I can't seem to fix that by changing the character set/encoding.
View 3 Replies
Dec 11, 2011
Last year (2010) I came across a FANTASTIC command that allowed me to take a string of variables with a common delimiter and break it all back out into separate variables (possibly an array) with one statement.
[Code]...
As long as the delimiter was a unique specifiable character, this one-statement command could break it out into elements. my memory and point me in the right direction.
View 2 Replies
May 26, 2011
I've read numerous posts and threads about random number generation, but I havent' run across this.If I generate a bunch of random numbers, the results are radically different if I create a new Random generator for each number than if I use on Random generator for all the numbers. The results are much more consistent and evenly distributed if I use the same Random generator.I would have thought the opposite,because creating a new Random generator each time should reduce the number of random repetitions, if a different time slice is used to create the random number.[code]......
View 9 Replies
Sep 27, 2010
I have code, shown below, that works all except for 1 thing: The variables being passed byRef get passed, but once modified in the else section of the "if me.invokerequired" code of RecordData, the variables are never updated in the calling function. To reiterate, the calling function does not receive the updated data that is in the variables custid and amt.When debugging, I see the data change in the else section of "if me.invokerequired", but once it returns from the callback the data is missing.[code]
View 15 Replies
Mar 23, 2012
I define some global variables of a class as follows:
Private Class MyClass
Private var1 as Decimal
Private list1 as List(Of string)[code].....
But I found that after this form is closed, all above variables, var1, list1, list2 still exist in memory. I thought they should be collected by gc since the form is already disposed as I confirmed.
Add: I have monitored half an hour after the form is closed. But these variables are not collected by gc. I have an automatic update procedure on the form which uses above variables.Since the above variables still hold values, the automatic update procedure is always called which causes exception. (One quick fix is to check if form.isDisposed in update procedure. But I do not think this is elegeant. Besides, these variables occupy memory.)
View 2 Replies
Apr 4, 2010
The class Random is out right defective. It always produces the same random numbers in the same sequence. Things I have tried so far is every kind of seed you can think of as well as Randomize. The result is that I always get the same random numbers in exactly the same sequence.
View 4 Replies
Nov 26, 2011
I am practicing using the drawing commands, and have gotten a grass background and black happy face that moves around the background.It's a 10x10 grid of 50 pixels.I want (at the moment, when i press enter) it to generate a random number of trees (15 ~ 25) at random locations on the background. The program doesn't freak out about anything, and the variables seem to be right (using stop commands) but it's not drawing anything. Here is the code for the "GenerateTrees" command I have for when I press enter.
Private Sub GenerateTrees()
NumberOfTrees = Int(Rnd() * 10) + 15
For i = 0 To NumberOfTrees - 1
bmap.MakeTransparent(Color.Fuchsia)
[code].....
View 4 Replies
Oct 10, 2011
I would like to use integers generated by Random.org in a small desktop widow app. Im using visual basic. All My search terms bring up unrelated (to My issue) information. Currently I am using the local random statement/command.
View 4 Replies
May 29, 2011
I am trying to make a texas hold em game and it is of the utmost importance that my code generate a random number. But using a random number function that I always end up with a lot of the same numbers over and over again. Any ideas on how to make it "TRULY" random? [code]
View 3 Replies
Jan 7, 2010
Does the memory used in declaring variables are reclaimed by the OS when these variables go out of scope?Does the memory used be released by setting thier value to nothing? if not, then how can I force the garbage collector to run or excecute at a certain/desired time..How about in Windows Forms..How can we make sure that the memory used in initializing and showing forms be released if those forms were closed?
View 13 Replies
Mar 8, 2011
Question 1: What is the difference between "Background Worker" and "Worker Pool" as indicated within the MSDN samples provided.
Question 2: I noticed while using, AddressOf _Function_, variables cannot be passed; what would be an efficient solution to this?
Question 3: While using multithreading is it required to invoke before setting variables, or only form properties?
Question 4: While using System.Net.Sockets is it safe/efficient to use Application.DoEvents while waiting for new data; or would be using a Do While loop be fine without DoEvents since the action would be multithreaded? Note: there can be up to 2000-3000 sockets in use at a time.
View 10 Replies
Jun 9, 2012
I'm new in .NET programming.I have a class Form1 that includes Button1_Click event.Button1_Click creates a multiple Text Boxies at run time)Here is the class:
Public Class Form1
Dim shiftDown As Integer
Dim counter As Integer
[code].....
View 3 Replies
Apr 19, 2012
I've made an image viewer which opens a random image from a specified folder, but the random number is not that random at all... I've already used Randomize(), but without result.
View 3 Replies
Nov 24, 2009
I don't take programming lessons at school or anything, and I'm starting to (try to) teach myself about random things.Currently I'm making an app that has 3 functions:
-Random Integer (1 to 100)
-Random Answer (Yes or No, similar to a coin flip)
-Random Dice Roll (1 to 6)
How would I go about doing this?At the moment all I know about random numbers etc. is that I will need to do something along the lines of Dim dice As New Random or something like that, but, like I mentioned, I have no idea.I am well aware of the DIC rules that you won't write the code for me/do my "homework(?)" for me, and that's not what I'm asking.
View 2 Replies
Nov 26, 2011
VS2010 (SP1) / .NET 4 on Windows XP. The question is simple, the answer; not so much. When generating a salt, should the LENGTH of the salt be random, fixed or a random number within a (min/max) range? I am using RNGCryptoServiceProvider to generate the salt, just unsure of the length of the salt.
View 12 Replies
Nov 25, 2009
I got a loop like this:
For KeywordsLoop = 1 To 150
TextFile1.WriteLine(RandomSuffix())
Next
[code].....
View 4 Replies
Dec 14, 2009
I have text for example:11.12.2009 or 7.8.2004 and how to get three variables, a, b, c
a = 7
b = 8
c = 2004
View 8 Replies
Jul 10, 2011
Is it in VB.NET possible to use variables without the need of use DIM? Now I have to use the variables like this:
dim a = 100
dim b = 50
dim c = a + b
I want to be able to use vars in this way:
a=100
b=50
c=a+b 'c contains 150
I think in VB6 and older VB this was possible, but I am not sure.
View 2 Replies
Feb 6, 2012
This is the updated code:
sql = "INSERT INTO Strings (String_Name, Long_Text, Short_Text, Alternate_Text, Multi_String_ID, Lang_ID) VALUES (?,?, ?,?,?,?)"
Dim command = New OleDbCommand(sql, pConn)
command.Parameters.AddWithValue("@webStringName", "String_Name")
[code]....
I am trying to create and INSERT statement with and OLE adapter. I had it working without paramtersm but now I am trying to add parms and am having issues with the syntax.Here is the code so far...
command = New OleDbCommand(sql, pConn)
sql = "INSERT INTO Strings (String_Name, Long_Text, Short_Text) VALUES (?,?, """ & ptsShortText & """)"
command.Parameters.Add("@webStringName", OleDbType.VarChar, 250, "String_Name")
command.Parameters.Add("@webLang_String", OleDbType.VarChar, 250, "Long_Text")
[code]....
Was just trying to get the first two variables parametrized.
View 1 Replies
May 3, 2011
I'm sure I'm doing something wrong; but this has been driving me crazy for a while now.I've made a small Silverlight game (an old Galaxian clone). When the game starts ~90% of the time, a bunch of stars are randomly positioned in the game area. There are three types of stars - bigger stars more faster, smaller stars move slower.
[Code]...
View 2 Replies
Jul 14, 2011
I used to add 2 strings variables and it works but when I tried using VB2008 it didn't work. [code]
View 9 Replies
Sep 30, 2009
I got a problem dealing with variables: I would like in an if-then-else following
If FZ1_KaskoTextBox.Text = 1 And Grundwert_Kasko <= 10000 And FZ1_BMComboBox.Text = 9 Then PraemieKasko_KFZ1_Var1 = 169.33 And PraemieKasko_KFZ1_Var2 = 169.33 Else
But the variables don't get filled?! is there any possibility to fill two variables within one "then" ...
View 5 Replies
Sep 22, 2011
s1nickelFrontImage is a declared variable, and I have others similar to it, they run up to 10.
how can I append/change the variable 's1nickelFrontImage1' to 's1nickelFrontImage2', and so forth, until LOOP is complete.(always increases by 1)
Do While ac1IMGPtoCCount > 0
ac1ImgPtoCString = ac1ImgPtoCString & s1nickelFrontImage1
ac1IMGPtoCCount = ac1IMGPtoCCount - 1
Loop
View 1 Replies
May 14, 2012
I have an ASP.NET application that I am developing. I'm using session variables within the app.In Firefox & Chrome, they all work.But in IE (ver 9), there's one variable that's not working. I'm not sure if it's a storage or a retrieval (or both) at this point. The variable in question that I'm storing is a List(T) type. It's the only one of it's kind that I'm using. Can't help but think there's a correlation there.One other old post mentioned the possibility that cache is causing the problem, but I didn't understand the answer very well.
Dim Rec_IDs As New List(Of String)
Rec_IDs = Session("Rec_IDs")
and
Dim Rec_IDs As New List(Of String)
[code].....
View 1 Replies
May 19, 2009
I want to have a random number between 1 to 6 but i got 0 - 5
View 5 Replies
Mar 11, 2012
I currently have code that creates and inserts ~175,000 names into a table.
What is the quickest way to collect a random first and last name? So far I have tried, Reading from two text files where every name is one line it takes ~2:30 minutes Reading from a table with [first][last] columns takes ~4 minutes
View 4 Replies
Mar 19, 2010
I have a CSV file with 35 fields. I have to read it into 35 variables. i know I can read the line, split it, write 35 assignment statemens. I am looking for an easier way (because I am lazy).
I'm looking for something like ReadCsvFile (A1, A2, A3, A4...A35) that will read a line, split it, and make all the assignments.
View 1 Replies
Jul 26, 2010
I actually came from VB6 and starting to learn VB.NET. I saw this line of code which I cannot understand how it works nor how it goes.
Private MAX_VALUE As Integer = (1 << 14)
View 2 Replies