Error With Rolling A Dice

Oct 31, 2011

I'm trying to create a game that involves rolling a dice. When I load the program and click the btnRoll button, the dice works fine and stops after a random number (between 10 and 20) of face changes. It then records the score in the a new line in a ListBox. Only problem is, when I press the roll button again, the face only changes once before recording the result.

I have tried creating a separate program that simply rolls the dice without recording the result, and it works fine. So I used roughly the same code in my game, but it still won't work. I have tried looking online for help for a few days now, so I figured this would be a good time to ask here.[code]...

View 8 Replies


ADVERTISEMENT

Game Programming :: Dice Rolling Program - When Using Rnd Fucntion How To Make It 1-6 Only

Dec 17, 2008

So my question is, I'm wiriting a VERY basic dice rolling program for my computer programming class in high school. I'm using a randomize function to generate numbers but I only want it to do numbers 1 - 6....how do I do this?

Dim x As Integer
Randomize()
x = CInt(10 * Rnd())

Dim Y As Integer
Randomize()
Y = CInt(10 * Rnd())

That is my code for my x and y (each die) to generate code, but how do I make it do 1 - 6 ONLY? Develope a game that in which a player rolls two dice. Each die has 6 faces. Each face contains 1, 2,3,4,5,6 after the dice have come to rest the sum of the spots is calculated, if the sum is 7 or 12 on the first throw, the player wins. If the sum is 2,3, or 11 on the first throw, the player loses, and the house wins. If the sum is 4,5,6,8,9,10 on the first throw the sum becomes the player's point. To win, a player must roll the dice until the plater rolls the point value. The player loses by rolling a 7 before rolling the point. I also have another question, How would I set this up to keep up with points and stuff? and the part that says "The player loses by rolling a 7 before rolling the point." I have no clue what to do on that. I'm not asking for code hand outs. I'm just asking what functions and such I'd use to write the code.

View 6 Replies

.net - Error When Rolling Out Software Revision To Terminal Sessions Instead Of Desktops?

Nov 15, 2010

I'm doing some maintenance on some software originally built by my predecessor at the company (who has since moved on to greener pastures). I'm currently rolling out a new version of the software. At this company, the installation procedure is basically to just shove the /bin/Release directory out into our automated program updater's magic directory, allowing it to automatically copy the contents of that directory over to the local /Program Files/ and let the magic happen. The magic always seems to happen, so there's no big issue, there, although it does weird me out somewhat, after many years of .msi installers...

[Code]...

View 2 Replies

How To Create A Rolling Percentage From A Log

Apr 7, 2011

I would like to have some sort of percentage on the amount of times each button has been pressede.gButton 1 is pressed 5 times, button 2 is pressed 3 times, button 3 is pressed 2 times.I would like this to create a percentage output onto the same form that is updated everytime a button is pressed on the form.

View 5 Replies

VB OracleTransaction Not Rolling Back

Sep 14, 2010

I'm calling a third party stored procedure in Oracle from VB that is not rolling back.

Code first (I'm simplifying):

Connection string:
String sqlstr = "SERVER=x.x.x.x;Database=db;uid=sa;pwd=admin;Connect Timeout=60; Min Pool Size=5; Max Pool Size=100;";

The call (I've just forced a rollback immediately after the execute to test it):

Dim Oraclecon As New OracleConnection(_OracleConnection)
Dim sqlCon As New SqlConnection(_SQLConnection)
Dim oTrans As OracleTransaction = Nothing

[Code.....

I can't give the details of the stored procedure but it does a commit and rollback inside it.

Either way, it is doing an insert, and that immediate rollback does not rollback the insert.

View 2 Replies

ASP.Net Grid View Rolling Total In Gridview

May 10, 2009

However in my opinion they require a lot of prior knowledge on how to programatically refer to each item.

Does anyone have a link to or can create a relatively basic example of how to achive a running total in the footer for an ASP:Gridview?

View 3 Replies

Calculating The Rolling Average In Crystal Reports?

Jun 17, 2009

I'm trying to calculate the rolling average in a crystal report. I have got 4 weeks in a month, and I have calculated the average for each week so long. Now I want to calculate a rolling average. eg:

For week1: rolling average = (week1Average)/1
For week2: rolling average = (week1Average + week2Average)/2
For week3: rolling average = (week1Average + week2Average + week3Average)/3
etc.

The problem with the code below is that, it is not looping through,therefore the rolling average for each week is the same as its average value wich is not correct.

Dim i, weekNum as number
Dim tot as double
weekNum =Distinctcount({ItemRating.WeekNo})

[Code].....

View 1 Replies

Rolling Back A Transaction With MySQL Connector?

Mar 23, 2011

I have one multi-row INSERT statement (300 or so sets of values) that I would like to commit to the MySQL database in an all-or-nothing fashion. insert into table VALUES

(1, 2, 3),
(4, 5, 6),
(7, 8, 9);

In some cases, a set of values in the command will not meet the criteria of the table (duplicate key, for example). When that happens I do not want any of the previous sets added to the database. I've implemented this with the following code, however, my rollback command doesn't appear to be making a difference. I've used this documentation: http://dev.mysql.com/doc/refman/5.0/es/connector-net-examples-mysqltransaction.html

Dim transaction As MySqlTransaction = sqlConnection.BeginTransaction()
sqlCommand = New MySqlCommand(insertStr, sqlConnection, transaction)
Try

[code]....

I get the DUPLICATE KEY exception thrown, no Rollback Exception thrown, and every set of values up to duplicate key committed to the database.

View 1 Replies

Setup Is Not Rolling Back If Condition If False

Jun 11, 2011

if one installer class in my project and in custom action doing some procedure to validate the serial key using user interface editor during setup creation. while installing the set up if the condition is not true the setup in rolling back it is installing.

[Code]...

View 1 Replies

Random Number Generator - Simulating Rolling Of Two Dices

Sep 11, 2011

I have a certain problem with 2 number generators that I have. My problem is that I want them to act individually. To where they seperatly come up with a random number. Mine is from 1-6 for 2 random number to simulate the rolling of two 6 sided dice. The problem that I have is that when I run the program they always generate the same number no matter what that number is. When I step through it step by step while the program is running in the debug screen they come up with a different number. This is in visual basic 2010 express edition.

Private
Sub
Button1_Click(ByVal
sender As
System.Object,
[Code] .....

View 3 Replies

Use To Get Random Dice

Jan 12, 2012

can someone tell me what do i use to get the random dice i don't know what code to use.

View 4 Replies

Data Designers/wizards So Good Now That Rolling Own Is No Longer Worth While?

Apr 9, 2010

Coming form too many years of VB6 I have a natural inclination to write my own data access code, etc. rather than using database wizard, etc. Same goes for using simple databinding to recordset rather than managing object collections and tying those to controls

I am finally moving to VB.NET and find myself on a solo project without any team on which to lean, so I have a couple related questions as I try to get my head around the transition. The project is basically a line of business app with a SQL Server back end.

1. Are the data designers/wizards so good now that rolling your own is no longer worth while?

2. Is the data-binding now fast, flexible, and reliable?

3. Can you recommend a good book or robust on-line tutorial that covers this sort of programming? 2008 or 2010 preferred.

View 1 Replies

Creating A Dice Class

May 24, 2010

I'm working on the code I used to make the animated dice program in my sig. I've done a bit of modding on it so I can re-use parts and it still worked fine, until I tried to put everything in a class so that I could just create new instances of a certain die.

I was heading towards the idea of creating a new instance of the die by a number in a textbox on the main form. Right now I am just working on the basic d6 just to get it up and running.

QuoteAn error occurred creating the form. See Exception.InnerException for details. The error is: The form referred to itself during construction from a default instance, which led to infinite recursion. Within the Form's constructor refer to the form using 'Me.'

I am probably going about this the wrong way all together and could use some help because I can't see how the class is referring to itself at all.

[code...]

doesn't look much better in the original program, but it actually works in that so if it helps just click the link in my sig to go to the post with the original download.

Since I am going to want all the various dice to Rotate() and Move(), I am wanting these to be generic so that I can use them no matter which die is trying to access it which is why I have tried putting them separately in their own subs and just passing the picture ByVal. I'm not sure if, or how, to put these in classes of their own or not.

And I have looked at just about every dice roller and Yahtzee example I can find, but none of them actually try to rotate the dice like I have, and they pretty much just calculate by using simple random values...which is okay, but does squat when the values are actual objects instead of numbers (if that makes sense).

Nothing I can find tries to put this stuff in classes, which makes it even harder to determine what really should go in the class files themselves. I really just can't find an example that I have been able to get to work for my purpose, nor figure this out on my own.

View 14 Replies

Dice For Snakes And Ladders?

Oct 17, 2010

im not too sure what is wrong with this code it seems to be right but the variable dice keeps coming out as

While diceshuf <= 6
select1 = Int(Rnd() * 6) 'random changing of dice picture before number is selected (purely astetic)

[code].....

View 3 Replies

2 Dice Roll And Percentage Calculator?

Nov 13, 2011

I need to make a program in VB but I have absolutely no idea what to do or how to write the code for it.The program needs to roll 2 dice comprised of picture boxes (one large picture box with 7 small picture boxes inside it for each) add the two numbers together and then calculate the percentage of each total number per roll.

I'd just like to say please bear with me. I'm a total newbie to coding. I know a little bit of web development but I'm incredibly new to making programs. Teach me and I'll get better, I promise.

View 4 Replies

Dice Roll Simulation With Rnd Function?

Apr 9, 2009

dice roll simulation with Rnd function

View 4 Replies

VS 2008 3 Dice Game + Accumulators?

Jul 3, 2009

I am new to this forum. Please let me know if there is a similar thread i should look at first.I'm working on a dice game and i'm kinda stuck on how to accumulate scores. I have been able to successfully create the rolling of the dice through a function shown below;

[Code]...

View 8 Replies

VS 2010 Dice Roller Using Classes And OOP?

Nov 16, 2011

For a class project (online course, no instructor handy to get a quick reply from -_-) we are to write a short program using classes and OOP to roll a pair of 6-sided dice 1000 times and count the number of times the total of the two dice is 7. Easy enough, and I've read over a few examples that people have written, but they don't seem to use OOP. I'm not asking you guys to do my homework for me, but I am terribly lost when it comes to using OOP. So far I understand that I should be using a Random() class object to determine the roll itself, and then maybe load each roll into an array and use a loop to check if each element is 7 or not, and then increment a counter? How do I set the range of Random() so my dice rolls are representative of a 6 sided die? It's all a bit overwhelming and I'm not sure what I should do next.

[Code]...

View 28 Replies

Sql Server - Rolling Back Entity Framework Transaction, Cached Item Persist?

Aug 23, 2011

I'm using an Entity Framework context, and sometimes would like to create a transaction so that the client can do multiple changes and then commit/rollback them all together.However, if many changes were made, and SaveChanges() was called multiple times, after which a rollback is called, entities that were commited already, will remain the way they were commited, and would not roll back.Here's how my transaction-relative functions look like:

Public Sub BeginTransaction()
Dim context = HttpContext.Current.GetObjectContext()
If Not context.Connection.State = ConnectionState.Open Then
context.Connection.Open()
End If

[Code]...

Not only does the test fail, but it also leave the ObjectContext in an unstable mode, because it still has invalid changes in it.

View 1 Replies

VS 2010 Make Dice Roll Program?

Mar 8, 2011

First let me say yes this is for homework and no, I DO NOT want an answer in code. A simple nudge in the correct direction will suffice.Basically I am attempting to roll the dice with the roll button and then display the number of times a number shows up with a bar graph.

View 2 Replies

Function That Checks For Which Dice Have Been Rolled And Scores Them Up In Correct Boxes

Jun 2, 2010

I have a function that checks for wich dice have been rolled and scores them up in the correct boxes, now i want to be able to check the combined scores to see if they equal upto a full house. [code] and then listing every other possible combination, would there be a simpler way of doing it?

View 2 Replies

If - Then - Message Box To Pop Up If No Dice Are Selected And The User Clicks The Roll Button

Jan 23, 2010

I'm using VB2008 express. idea for a D&D application. So I wrote something and it works, but it's not coded like I want. Here's the program if you want to see it in operation: [URL]

Here's the problem I have. I want a message box to pop up if no dice are selected and the user clicks the roll button. So far the only way I have been able to accomplish this is to put the same code under each radio button:

Code:
RolledValueTextBox.Visible = True
Label1.Visible = True
Label2.Visible = True
YesRadioButton.Visible = True
NoRadioButton.Visible = True

I want to have this code only once. But If I put it outside of the If/Then bracket and no dice are selected, the msgbox pops up but also the buttons that I want to remain hidden until dice are chosen pop up. How do I get the msg box to pop up and stop...don't execute any more code.

Heres' the code so far. trying to keep it relatively simple:

Code:
Private Sub RollButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RollButton.Click
'see which radio button is checked and display random number accordingly
If TwentySidedRadioButton.Checked Then
RolledValueTextBox.Text = GenerateRandom.Next(1, 20)

[CODE]...

View 5 Replies

Create A Random Number Generator (dice Roller) That Will Dump Its Results Into An Open Chat Window?

May 17, 2009

I am trying to create a Random Number Generator (dice roller) that will dump its results into an open chat window. I was lead towards using DDE but have never used it before. Is this the best method? if not, What is?

View 1 Replies

VS 2010 : Create A Program That Rolls A Dice A User Generated Number Of Times And Give The Frequencies Of The Numbers That Come Up?

Oct 26, 2010

I need to create a program that rolls a dice a user generated number of times and give the frequencies of the numbers that come up.I cannot for the life of me figure out how to get the frequencies?

View 5 Replies

Game Programming :: Pig Dice Game - When Program Runs - Never Goes To Computer's Turn And Does Not Update Users Score Either

Apr 18, 2012

On programming assignment without having any real experience in vb. I guess I don't understand subroutines that well. When the program runs it never goes to the computer's turn and does not update the users score either. This assignment is already in but would like to know what is going wrong. Using VB 2010, and this is windows application.

Code:
Public Class Form1
Dim Myturn As Integer
Dim Computerturn As Integer

[CODE]...

View 6 Replies

"Roll The Dice" Button

Oct 26, 2011

If I'm making an application using two dice images and the button I click changes those two images to random dice - what is the code for that? I have already made my dice images using paint, what is the code I use so that whenever I click the "Roll the Dice" button, it goes to two random dice images?

View 1 Replies

Programs To "Toss Dice"?

Jul 20, 2010

I've seen several questions come up about making a program to "toss dice", so I thought that I'd add a few resources that those interested might find helpful:

[url]...

I put them together and hope that others might find some use from them. I might could also do something in 3D but that'd take a while!

As an example of the images, here are two screenshots of a little program I did to show them

[code]...

View 10 Replies

Create "a Windows Form Game Called Yahtzis Which Uses Five Dice And Three Throws To Create A Score"?

Oct 18, 2010

i am suppose to create "a windows form game called Yahtzis which uses five dice and three throws to create a score" .

The problem is that i don't even know how to start it can anyone shed some light.

View 2 Replies

IDE :: Error Like It "An Error Occurred Creating The Form. See Exception.InnerException For Details. The Error Is: Attempted To Read Or Write Protected Memory

Aug 11, 2009

I have a project that reference from leadtools 16.5, and after that, i want to run my project..i see am error like it " An error occurred creating the form. See Exception.InnerException for details. The error is: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. im using vb 2008 pro

View 6 Replies

Asp.net - Get The Error Page : Server Error In '/' Application. HTTP Error 403 - Forbidden?

Aug 9, 2011

I'm using Visual Studio Development Server (Visual Basic 2010) and it works fine. Now I've enabled NTLM Authorization because I want to test the website using a different user account. Now when I try to access the website I always get the following error page:

Server Error in '/' Application.

HTTP Error 403 - Forbidden.

Version Information: ASP.NET Development Server 10.0.0.0 .I'm using a test account which is a normal user within our domain. I've already set the access rights in my project folder to Full Access for this user but it does not help.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved