0

I've been searching a lot, but couldn't find anything about what I would imagine to be pretty easy.

I'm trying to get a number out of a List, that is getting information out of an Excel file. But I don't think that matters.
I then want to give it a percentage, but it doesn't want to see the list as a value.

So I figured I would put the List Value into a Text Value, to then calculate it.

Private Sub cmdBereken_Click()

Text1.AddItem (lstPrijs.Text)

prijs = Val(Text1.Text)
percent = 1 + Val(Text2.Text) / 100

eind = prijs * percent

Text3.Text = eind

Text2 = ""

End Sub

Can anyone help me with this?

Thanks in advance,

Q~

2
Contributors
2
Replies
4
Views
9 Years
Discussion Span
Last Post by Qpido
0

I've been searching a lot, but couldn't find anything about what I would imagine to be pretty easy.

Private Sub List1_Click()
   Dim strListValue As String, sngPercentage As Single
   strListValue = List1.List(List1.ListIndex)
   ' Check for numeric value to avoid run time error
   If IsNumeric(strListValue) Then
      Text1 = Format(CDec(strListValue) * sngPercentage, "currency")
   End If
End Sub

Edited by pritaeas: Fixed formatting

0

Thanks, that solved it.
I used it differently though:

Private Sub lstPrijs_Click()

   Dim strListValue As String
   strListValue = lstPrijs.List(lstPrijs.ListIndex)

   If IsNumeric(strListValue) Then
      Text1 = strListValue
   End If

End Sub
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.