0

my code is working fine, but the output shows for example 12345.000

i would like to only show the data before the .000 is this posible?

Private Sub GetCurrentJanVOL()
        Dim con As New SqlConnection
        Dim cmd As New SqlCommand
        Try
            con.ConnectionString = "Data Source=" & ServerV & ";Initial Catalog=" & databaseV & ";Persist Security Info=True;User ID=" & usernameV & ";Password=" & passwordV & ""
            con.Open()
            cmd.Connection = con
            cmd.CommandText = "SELECT SUM(QtyInvoiced) AS JanVol FROM ArTrnDetail where (Customer = '" & Me.LBCustomer.Text & "') AND (TrnYear ='" & Me.LBcurrentyear.Text & "') AND (TrnMonth = 1)"
            Dim lrd As SqlDataReader = cmd.ExecuteReader()
            While lrd.Read()

                Me.LBcurJanVol.Text = Convert.ToString(lrd("JanVol"))

            End While
        Catch ex As Exception
            MessageBox.Show("Error while getting Current year volume for Jan")
        Finally
            con.Close()
        End Try
    End Sub
Attachments image1.jpg 21.9 KB
3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by Unhnd_Exception
0

If the value from the reader "JanVol" will always be numeric:

CInt(lrd("JanVol")).ToString() 'Round up or down.
CInt(Math.Floor(lrd("JanVol"))).ToString() 'Round down.
0

thanks i thought this was sorted but it isn't as some times
the
Convert.ToString(lrd("JanVol")) is empty, when it is empty i get all kinds of errors.

is there anyway to trim the last 4 char of the string?

0

You can always use the Integer side for the format in a textbox

in example:

Dim p as Integer
If IsNumeric(TextBox.Text) Then
     p = Integer.Parse(TextBox.Text)
End If

that will also get take of does extra zero's

Regards,

0

Validate your data from the reader.

If lrd("JanVol") Is DBNull.Value Then
      LBcurJanVol.Text = "0"
Else
      LBcurJanVol.Text = CInt(lrd("JanVol")).ToString
End If
This topic has been dead for over six months. 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.