我喜歡從txt文件中讀取以下文本,但希望將三個數字中的每一個賦值給各個變量,我該如何執行此操作?分割字符串並將分割段分配給變量
(234.134, 105.087, 0.000000)
EDDIT:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String
Dim XVAL As String
Dim YVAL As String
Dim ZVAL As String
Dim strArr() As String
Dim count As Integer
str = "(0.123, 4.467, 8.910)"
strArr = str.Split(", ")
For count = 0 To strArr.Length - 3
XVAL = (strArr(count))
Next
For count = 0 To strArr.Length - 2
YVAL = (strArr(count))
Next
For count = 0 To strArr.Length - 1
ZVAL = (strArr(count))
Next
Label1.Text = XVAL + ZVAL
Label2.Text = YVAL
Label3.Text = ZVAL
End Sub
現在才XVAL和ZVAL的產品顯示爲0.123 8.910,而不是0.123 + 8.910 = 9.033
的9.033這是林後
我設法編寫了以下代碼(請參閱eddit) – alf 2010-11-29 15:28:16