help with array please

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2008
Posts: 74
Reputation: sacarias40 is an unknown quantity at this point 
Solved Threads: 0
sacarias40's Avatar
sacarias40 sacarias40 is offline Offline
Junior Poster in Training

help with array please

 
0
  #1
Nov 22nd, 2008
  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
mobcalc.jpg   mobcalc2.jpg  
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 305
Reputation: timothybard is an unknown quantity at this point 
Solved Threads: 25
timothybard's Avatar
timothybard timothybard is offline Offline
Posting Whiz

Re: help with array please

 
0
  #2
Nov 22nd, 2008
Here is some example code of how to set up an array:

  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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC