Yahtzee Totals
Yahtzee Totals
Yahtzee Totals
Yahtzee Totals
Yahtzee Totals
Yahtzee Totals Yahtzee Totals Yahtzee Totals Yahtzee Totals Yahtzee Totals Yahtzee Totals Yahtzee Totals Yahtzee Totals
Yahtzee Totals Yahtzee Totals
Yahtzee Totals
Go Back  Xtreme Visual Basic Talk > > > Yahtzee Totals


Reply
 
Thread Tools Display Modes
  #1  
Old 12-03-2009, 03:08 PM
jjss_19 jjss_19 is offline
Newcomer
 
Join Date: Nov 2009
Posts: 5
Default Yahtzee Totals


Hi I'm creating a modified version of Yahtzee game. I have a textbox in which when all the dice roll their totals all added up are shown in the textbox. I have the user rolling three times then the third roll's totals are shown. At the end of one round the total is shown. A problem i am having is when i start a new round the total is wiped out. How can i make it so that the total of a new round is added to the players existing total?

The code I have right now is:

'randomizing my 5 dice
Randomize
a=Int(Rnd * 6) + 1
b=Int(Rnd * 6) + 1
c=Int(Rnd * 6) + 1
d=Int(Rnd * 6) + 1
e=Int(Rnd * 6) + 1

t = a + b + c + d + e

imgDice1(a).Visible = True
imgDice2(b).Visible = True
imgDice3(c).Visible = True
imgDice4(d).Visible = True
imgDice5(e).Visible = True

If ct = 3 Then
txtsum.text = t
msgbox "begin new round"
cmdRoll.Enabled = true
Form_load
End If
Reply With Quote
  #2  
Old 12-03-2009, 05:01 PM
Qua's Avatar
QuaYahtzee Totals Qua is offline
Impetuous & volatile

* Expert *
 
Join Date: Apr 2005
Posts: 2,177
Default

I can't tell directly from your code why the total is being wiped out, however, I do have a feeling that calling Form_load is the wrong approach inside this function. If the variable t contains the total of a round, are you sure that you've declared this variable on a class scope, so it maintains it's value even the the function ends? Once the function ends all variables are "deleted" and thus their values will be reset next time this function is called.
__________________
Reading is the foundation for all knowledge - Unknown.
Reply With Quote
  #3  
Old 12-03-2009, 06:49 PM
jjss_19 jjss_19 is offline
Newcomer
 
Join Date: Nov 2009
Posts: 5
Default

The reason I am calling on form_load is because if I don't when I get into later rounds the dice eventually just stop randomizing and they sit on six. By calling on form_load its randomizing each and every round.
Reply With Quote
  #4  
Old 12-03-2009, 07:28 PM
Iceplug's Avatar
IceplugYahtzee Totals Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Is the total being stored directly into the textbox? Perhaps you should store the total in a variable. If you are indeed reloading the form, you should have the total in a Module.
Then, you store the value of total in the textbox (or label).
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #5  
Old 12-03-2009, 08:03 PM
jjss_19 jjss_19 is offline
Newcomer
 
Join Date: Nov 2009
Posts: 5
Default

I'm slightly new to VB6, how can i do that?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Yahtzee Totals
Yahtzee Totals
Yahtzee Totals Yahtzee Totals
Yahtzee Totals
Yahtzee Totals
Yahtzee Totals Yahtzee Totals Yahtzee Totals Yahtzee Totals Yahtzee Totals Yahtzee Totals Yahtzee Totals
Yahtzee Totals
Yahtzee Totals
 
Yahtzee Totals
Yahtzee Totals
 
-->