2010-04-03 4 views

답변

9
Math.Truncate(myDecimal) 

만 정수부두고 소수 부분을 벗겨 것이다. (. 종류를 변경하지 않으면 서,, 즉,이뿐만 아니라 인자의 유형을 리턴 할 것이 Double 또는 Decimal) .

3

정수로 변환하십시오.

Dim myDec As Decimal 
myDecimal = 532.016 
Dim i As Integer = Cint(myDecimal) 

'i now contains 532 
+0

그 방법에 대한 전체 코드를 알려주십시오. –

+0

OP는 질문 제목에 따라 10 진수를 사용했습니다. – Joey

+0

@Johannes Rössel - 내 눈이보다 선명한 ... 답변이 수정되었습니다. – Oded

0

당신은들을 System.Text.RegularExpression을 사용할 수

Imports System.Text.RegularExpressions 'You need this for "Split"' 

Public Class Form1 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 

     Dim yourNumber As String = 532.016 'You could write your integer as a string or convert it to a string' 
     Dim whatYouWant() As String 'Notice the "(" and ")", these are like an array' 

     whatYouWant = Split(yourNumber, ".") 'Split by decimal' 
     MsgBox(whatYouWant(0)) 'The number you wanted is before the first decimal, so you want array "(0)", if wanted the number after the decimal the you would write "(1)"' 

    End Sub 

End Class