Welcome to Dream.In.Code
Become a VB Expert!

Join 149,386 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,299 people online right now. Registration is fast and FREE... Join Now!




Help with Array

 
Reply to this topicStart new topic

Help with Array

km22
2 May, 2007 - 09:39 AM
Post #1

New D.I.C Head
*

Joined: 11 Mar, 2007
Posts: 32


My Contributions
I need to get an increase amount from an input box to increase the price by the amount put in the input box. I cannot figure out how to convert the entry in the input box to a decimal that should display in a listbox. Any help would really be appreciated.
This is my code:
CODE

Private Sub increaseButton_Click(ByVal sender As Object, ByVal _
    e As System.EventArgs) Handles increaseButton.Click


        Dim prices() As Decimal = {3.75D, 11.5D, 31.5D, 10D, 9.5D, _
        25.5D, 5.64D, 8.35D, 10.75D, 3.5D}
        Dim increase As Decimal
        Dim isConverted As Boolean
        Dim getIncreaseAmount As String
        Dim Prompt As String = "Enter increase"
        Dim Title As String = "Increase"


        getIncreaseAmount = InputBox("Enter price increase")

        isConverted = Decimal.TryParse(getIncreaseAmount)
        increase = getIncreaseAmount
        If isConverted Then
            For Each price As Decimal In prices
                price = price + increase
                newListBox.Items.Add( _
                 price.ToString("N2").PadLeft(6) _
                & ControlChars.NewLine)

            Next price
        End If

    End Sub

    
End Class

User is offlineProfile CardPM
+Quote Post

Jayman
RE: Help With Array
2 May, 2007 - 10:10 AM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,297



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
The problem here is the the TryParse function takes two parameters. The first is the String being converted and the second is the variable that is going to contain the converted Decimal value.

This should fix you up.
CODE

isConverted = Decimal.TryParse(getIncreaseAmount, increase)

User is online!Profile CardPM
+Quote Post

km22
RE: Help With Array
2 May, 2007 - 10:34 AM
Post #3

New D.I.C Head
*

Joined: 11 Mar, 2007
Posts: 32


My Contributions
Thank you! I made the change and took out this line

increase = getIncreaseAmount

And it works. Thx again!



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 09:54AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month