Home > OS >  how to format a string result consisting of 10 heats in total with 0 and the desired value
how to format a string result consisting of 10 heats in total with 0 and the desired value

Time:09-16

I have to insert the results of a query into a string of ten characters (numbers). The values must all be 0 and I need to replace only the last characters with those of the query cells.

My code:

Dim idClienteCosarConsorziati As New DataSet
idClienteCosarConsorziati = DB_SQL.OpenDataset("SELECT Anagrafica.ID_cliente FROM Anagrafica WHERE (((Anagrafica.ID_gruppo) Is Null) AND ((Anagrafica.ID_padre_consorzio)=13584))", "Anagrafica.ID_cliente")

Try
    Dim contenitore As DataTable = idClienteCosarConsorziati.Tables(0)
    For Each row As DataRow In contenitore.Rows
        For Each cells As String In row.ItemArray
            Dim stringtoserach As String = "E:\PDF_Fatture\"   Format(cells, "0000000000")
        Next
    Next
Catch ex As Exception
    MessageBox.Show(ex.Message)
End Try

I try with Format(cells, "0000000000") but the result does not have the 0s

CodePudding user response:

I did the smiliar task using this: More info about Right is here

Right('0000000000' cells , 10)

CodePudding user response:

String already has a function PadLeft

cells.PadLeft(10, '0')
  • Related