Hi @Hobbyist_programmer ,
If no quantity entered manually, cost will be calculated with default quantity.
I make a test based on your description, and you can refer to the following code.
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox2.DataBindings.Clear()
Dim testLst As BindingList(Of Test) = New BindingList(Of Test)()
Dim result As Integer
If Integer.TryParse(TextBox1.Text, result) Then
testLst.Add(New Test() With {
.Quantity = result
})
Else
testLst.Add(New Test())
End If
TextBox2.DataBindings.Add("Text", testLst(0), "Quantity")
End Sub
End Class
Public Class Test
Private QuantityValue As Integer = 1
Public Property Quantity() As Integer
Get
Return QuantityValue
End Get
Set(ByVal Value As Integer)
QuantityValue = Value
End Set
End Property
End Class
Result of my test.
Best Regards,
Xingyu Zhao
*
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.