[英]How to redirect Output of console application to Textbox control on a windows form at run time using vb.net 2012
[英]How to set a Textbox value as double and make is empty without using “ ” in VB.net windows form application?
這是代碼
Public Partial Class MainForm
Public Sub New()
' The Me.InitializeComponent call is required for Windows Forms designer support.
Me.InitializeComponent()
'
' TODO : Add constructor code after InitializeComponents
'
End Sub
Sub Label4Click(sender As Object, e As EventArgs)
End Sub
Sub Button2Click(sender As Object, e As EventArgs)
Dim poundInAKg As Double = 2.20462
Dim KGInAPound As Double = 0.453592
If pound.Text = " " Then
MessageBox.Show("Please fill atleast one value Kilo or Pound : ")
End If
kilo.Text = Val(pound.Text) * 0.453592
'pound.Text = Val(kilo.Text / 2.20462 )
End Sub
Sub MainFormLoad(sender As Object, e As EventArgs)
End Sub
End Class
錯誤是從“雙精度”到“字符串”的隱式轉換。 (BC42016)請幫助
您應該使用double.TryParse方法嘗試將用戶輸入(字符串)轉換為雙精度值,然后,如果轉換成功,請執行moltiplication並將所有內容重新轉換為字符串
Dim poundInAKg As Double = 2.20462
Dim KGInAPound As Double = 0.453592
Dim poundVal As Double
if double.TryParse(pound.Text, poundVal) Then
kilo.Text = (poundVal * 0.453592).ToString()
else
MessageBox.Show("Please fill atleast one value Kilo or Pound : ")
End If
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.