943,856 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 841
  • VB.NET RSS
Nov 22nd, 2008
0

help with array please

Expand Post »
VB.NET Syntax (Toggle Plain Text)
  1. Public Class Form1
  2.  
  3.  
  4. Private Sub TextBox1_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.MouseHover
  5. ToolTip1.SetToolTip(TextBox1, "Cash Flow")
  6. End Sub
  7. Private Sub TextBox2_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.MouseHover
  8. ToolTip1.SetToolTip(TextBox2, "Account Balance")
  9. End Sub
  10.  
  11.  
  12. Private Sub TextBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
  13. TextBox1.Clear()
  14. End Sub
  15.  
  16. Private Sub TextBox2_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox2.MouseDown
  17. TextBox2.Clear()
  18. End Sub
  19.  
  20.  
  21. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  22.  
  23. 'these variable need to plug into an equation
  24. dim name as string
  25. Dim current As Decimal
  26. Dim toBuy As Integer
  27. Dim startPrice As Decimal
  28. Dim newPrice As Decimal
  29. Dim totalNeed As Decimal
  30. Dim quantity As Integer
  31. Dim subNeed As Decimal
  32. Dim account As Decimal
  33. Dim flow As Decimal
  34. Dim hours As Decimal
  35.  
  36. 'this is the equation
  37. newPrice = current + (toBuy) * (0.1 * startPrice)
  38.  
  39. totalNeed = newPrice * quantity
  40.  
  41. subNeed = totalNeed - account
  42.  
  43. hours = subNeed / flow
  44.  
  45. MsgBox("it will take you " & hours & " hours to save up for " & quantity & name & "'s. ")
  46. End Sub
  47. End Class

for example, the plaza that i was about to click on (in the pic)
it is in combobox1, it is plaza, and its starting price is 1000000 dollars.

it has a starting price, but depending on how many somebody already owns it has a current price. you can find out the current price by plugging what you know into the equation:
newPrice = (current) + (toBuy) * (0.1 * startPrice)
you then plug the rest of these into some more code(not shown yet) to get the hours to save up.

my question is, how do i make an array that has the name and starting price associated with the combobox1.

so when i click the plaza it plugs the startPrice into the equation and it plugs the name into the msgbox output string.

please help, ive been struggling with this for a couple weeks now.
best regards!!!
Attached Thumbnails
Click image for larger version

Name:	mobcalc.jpg
Views:	39
Size:	14.0 KB
ID:	8310   Click image for larger version

Name:	mobcalc2.jpg
Views:	40
Size:	10.0 KB
ID:	8311  
Similar Threads
Reputation Points: 11
Solved Threads: 4
Junior Poster
sacarias40 is offline Offline
113 posts
since Nov 2008
Nov 22nd, 2008
0

Re: help with array please

Here is some example code of how to set up an array:

vb Syntax (Toggle Plain Text)
  1. 'Declare Array
  2. Dim properties(3, 1) As String
  3.  
  4. 'Set values of Array
  5. properties(0, 0) = "Plaza"
  6. properties(0, 1) = "1000000"
  7.  
  8. properties(0, 0) = "Seaside Lot"
  9. properties(0, 1) = "1500000"
  10.  
  11. properties(0, 0) = "Restaurant"
  12. properties(0, 1) = "3000000"
  13.  
  14. 'Retreive values of Array
  15. Dim newPrice, current, toBuy As Double
  16. newPrice = current + toBuy * (0.1 * properties(0, 1))

I would actually recommend using an array of a Class instead of using a multidimensional array of type string.
Reputation Points: 27
Solved Threads: 29
Posting Whiz
timothybard is offline Offline
317 posts
since Mar 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Using Select Statement to retrieve data from SQL Server 2005 database
Next Thread in VB.NET Forum Timeline: error creating substring





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC