473,412 Members | 2,051 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

vb.net 2003 I am so lost

I am trying to create a coin toss game for class but me and programming are having a hard time getting to know one another.

my question is What is wrong with this code?
I really do alot better with networks hardware and software wish I didn't even have to do this because I am so confused

I am not done with alot of it and I have to rotate two images corresponding to picturebox and whether heads lands or tails

Expand|Select|Wrap|Line Numbers
  1.  Dim MyValue As Integer = Toss
  2.  
  3.         MyValue = CInt(Int((2 * Rnd())))
  4.         If MyValue = 0 Then
  5.             intHeads = intHeads + 1
  6.  
  7.  
  8.         Else
  9.  
  10.             intTails = intTails + 1
  11.  
  12.         End If
  13.         intTotal = intHeads + intTails
  14.         If radOne.Checked = True Then
  15.             intHeads = intHeads + 1
  16.         Else
  17.             intTails = intTails + 1
  18.  
  19.         End If
  20.  
  21.  
  22.  
  23.         PicCoin.Image = Image.FromFile("C:\Documents and Settings\Lauri\Desktop\#3projectvb\TossThatCoin\bin & m_strFile_Prefix & m_strFile_Suffix")
and thank you
Feb 26 '07 #1
8 1291
willakawill
1,646 1GB
Hi. What are you trying to do with this code and what is not working?
Feb 26 '07 #2
Hi. What are you trying to do with this code and what is not working?
hi I am trying to random number of tosses and pictures of tails and heads with this code I revised it some but it still not working right

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnToss_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnToss.Click
  2.         Dim MyValue As Integer
  3.         Dim x As Integer
  4.         For x = 0 To Toss
  5.             MyValue = CInt(Int((2 * Rnd())))
  6.             If (MyValue < 0.5) Then
  7.                 Heads += 1
  8.             Else
  9.                 Tails += 2
  10.             End If
  11.             intTotal += 2
  12.  
  13.         Next
  14.  
  15.         'Update Picture Box and Display Leading Output
  16.         If (Heads > Tails) Then
  17.             txtCurrentOut.Text = HEAD
  18.             PicCoin.Visible = True
  19.             PicCoin.Image = Image.FromFile("head.jpg")
  20.         ElseIf (Tails > Heads) Then
  21.             txtCurrentOut.Text = TAIL
  22.             PicCoin.Visible = True
  23.             PicCoin.Image = Image.FromFile("tail.jpg")
  24.  
  25.         End If
  26.  
  27.         'Update Displays
  28.         txtHeads.Text = Heads.ToString
  29.         txtTails.Text = Tails.ToString
  30.         txtTosses.Text = intTotal.ToString
Feb 27 '07 #3
Killer42
8,435 Expert 8TB
You need to be more specific than "not working". What is it doing, or not doing?

I did notice one or two things here...
Expand|Select|Wrap|Line Numbers
  1.         'Update Picture Box and Display Leading Output
  2.         If (Heads > Tails) Then
  3.             txtCurrentOut.Text = HEAD
  4.             PicCoin.Visible = True
  5.             PicCoin.Image = Image.FromFile("head.jpg")
  6.         ElseIf (Tails > Heads) Then
  7.             txtCurrentOut.Text = TAIL
  8.             PicCoin.Visible = True
  9.             PicCoin.Image = Image.FromFile("tail.jpg")
  10.         End If
  • Unless HEAD and TAIL are constants, they should be in quotes
  • The ElseIf (Tails > Heads) can probably just be written as Else. Also, note that your current test will not catch the situation where Tails = Heads.

Oh! And in this...
Expand|Select|Wrap|Line Numbers
  1. MyValue = CInt(Int((2 * Rnd())))
  2. If (MyValue < 0.5) Then
I don't think it makes much sense to compare an integer (whole numbers, remember) to 0.5.
Feb 27 '07 #4
You need to be more specific than "not working". What is it doing, or not doing?

I did notice one or two things here...
Expand|Select|Wrap|Line Numbers
  1.         'Update Picture Box and Display Leading Output
  2.         If (Heads > Tails) Then
  3.             txtCurrentOut.Text = HEAD
  4.             PicCoin.Visible = True
  5.             PicCoin.Image = Image.FromFile("head.jpg")
  6.         ElseIf (Tails > Heads) Then
  7.             txtCurrentOut.Text = TAIL
  8.             PicCoin.Visible = True
  9.             PicCoin.Image = Image.FromFile("tail.jpg")
  10.         End If
  • Unless HEAD and TAIL are constants, they should be in quotes
  • The ElseIf (Tails > Heads) can probably just be written as Else. Also, note that your current test will not catch the situation where Tails = Heads.

Oh! And in this...
Expand|Select|Wrap|Line Numbers
  1. MyValue = CInt(Int((2 * Rnd())))
  2. If (MyValue < 0.5) Then
I don't think it makes much sense to compare an integer (whole numbers, remember) to 0.5.

yes I see what you mean and what I mean is I am getting counts of tails and heads but by six's and the picture does not always load with the corresponding flip of the coin meaning if the text displays 6 times landing on heads the picture box is not displaying the head I am getting closer I now have percentages displayed thank you for your input
Feb 27 '07 #5
yes I see what you mean and what I mean is I am getting counts of tails and heads but by six's and the picture does not always load with the corresponding flip of the coin meaning if the text displays 6 times landing on heads the picture box is not displaying the head I am getting closer I now have percentages displayed thank you for your input
I did change the integer value to this
Expand|Select|Wrap|Line Numbers
  1. intRandom = CInt(Int((2 * Rnd() + 1)))     
  2.  
  3.  
  4.         For x = 0 To Toss
  5.  
  6.             If (intRandom < 2) Then
  7.                 Heads += 1
  8.             Else
  9.                 Tails += 1
  10.             End If
  11.             intTotal += 1
but still I think I am just really tired at the moment because its still not loading the pictures right
Feb 27 '07 #6
Killer42
8,435 Expert 8TB
I'll leave you to mull over it for the moment, because it's time for dinner, then bed (probably a different timezone). But I do have one question. What is the value of Toss?

Oh, and have you considered setting intRandom inside the loop?
Feb 27 '07 #7
I had forgotton to come back and say thank you for your help I did get it to finally work right
Thanks again
Mar 4 '07 #8
Killer42
8,435 Expert 8TB
I had forgotton to come back and say thank you for your help I did get it to finally work right
Glad we could help. :)
Mar 4 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: DL | last post by:
Hi, I'm lost right now... I used 'Visual Studio 2005 Beta Home' to make a small application. But since the computer i want to use it on has .Net 2003 installed I get a version error. This...
1
by: chris mancini | last post by:
I have recently installed Visual Studio .Net 2003 and have noticed that there are problems with formatting in the HTML code page. If I format the HTML the way I want and navigate back to design...
0
by: Nitec Dev | last post by:
Our setup: server1 ASP database running on IIS5, Outlook 2000 and SQL 2000 on Windows 2000. Server2 runs Windows 2000 with Exchange 2000 using CDO 1.2 MAPI Sessions. Clients use IE5/6 and had...
0
by: David G. | last post by:
The keyboard type ahead buffer does not seem to work in Access 2003 in certain situations. We would like some help with this. Here are the details. We have a large program that was developed...
3
by: Malcolm Webb | last post by:
My database was developed and is currently running in Access 2000. I am contemplating upgrading to the latest version of Access (2003?) running on new computers. Will there be any major...
3
by: Peter Oliphant | last post by:
In the 2002 version of VS C++.NET if I wanted to create a new Managed C++ application I would got to "New Projects", then select "C++ Projects," then "Managed C++ Application". I recently...
6
by: Winshent | last post by:
I have read many threads which indicate that this was a problem with version 2002. Why should i be suffering this? I am using VB.NET 2003 Standard Edition... is it still a problem with 2003? ...
6
by: DL | last post by:
Hi, I'm lost right now... I used 'Visual Studio 2005 Beta Home' to make a small application. But since the computer i want to use it on has .Net 2003 installed I get a version error. This...
2
by: Trev | last post by:
Hi, I need you suggestion and ideas as I am not a programmer by any means but I've been reading the articles on how to show a dynamic chart in asp web pages. I have to say it's brilliant and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.