Android Question How can i remove decimal points from the numerical values

Makumbi

Well-Known Member
Licensed User
Please help i have this return json values from my api but i do not want the decimal values please help
B4X:
[{"Account":"19-07561","Names":"MAKUMBI TARIQ AZIZI","Stream":"F","Class":"P1","Expressed":"MID TERM 1 2019","sstscore":64.0,"sstgrade":5.0,"engscore":75.0,"engrade":3.0,"mathsscore":49.0,"mathsgrade":8.0,"sciencescore":63.0,"sciencegrade":5.0,"totalscore":251.0,"Totalgrade":21.0,"Division":"2","ire":"","iregrade":"","Years":2019.0,"atk":1},{"Account":"19-07561","Names":"MAKUMBI TARIQ AZIZI","Stream":"F","Class":"P1","Expressed":"END TERM 1 2019","sstscore":70.0,"sstgrade":3.0,"engscore":70.0,"engrade":3.0,"mathsscore":60.0,"mathsgrade":5.0,"sciencescore":68.0,"sciencegrade":4.0,"totalscore":268.0,"Totalgrade":15.0,"Division":"2","ire":"","iregrade":"","Years":2019.0,"atk":2}]

B4X:
            Dim jt As HttpJob
            jt.Initialize("", Me)
            jt.Download("http://kccug.com/KABOJJAAPPAPI/api/HandlerVBArchivebxV2/GetCustomersJSON")
            
            'jt.GetRequest.Timeout =2000 '10 seconds
    
            'Sleep(0)
            Wait For (jt) JobDone(jt As HttpJob)
            If jt.Success Then ' if job is success (http status code 200)
                Dim RetVal As String
                RetVal = jt.GetString
                Log(RetVal)
                If jt.GetString = "[]" Then
                    xui.MsgboxAsync("No Past Performance for this Child","SMIS KABOJJA")
                    ProgressDialogHide
                    Return
                Else
                    'Expressed, sstscore, sstgrade, engscore, engrade, mathsscore, mathsgrade, sciencescore, sciencegrade, totalscore, totalgrade
            
                    Dim jp As JSONParser
                    jp.Initialize(jt.GetString)
                    'Log(jp) ' will pr
                    Log($"Token(${jp})"$)
                    Dim quotdt As List = jp.NextArray
                    For Each quotd As Map In quotdt
                        Log("admno: " & quotd.Get("Account"))
                        Log("Stream: " & quotd.Get("Stream"))
                        Log("Names: " & quotd.Get("Names"))
                        Log("Class: " & quotd.Get("Class"))
                        Log("Expressed: " & quotd.Get("Expressed"))
                        Log("sstscore: " & quotd.Get("sstscore"))
                        Log("sstgrade: " & quotd.Get("sstgrade"))
                        Log("engscore: " & quotd.Get("engscore"))
                        Log("engrade: " & quotd.Get("engrade"))
                        Log("mathsscore: " & quotd.Get("mathsscore"))
                        Log("mathsgrade: " & quotd.Get("mathsgrade"))
                        Log("sciencescore: " & quotd.Get("sciencescore"))
                        Log("sciencegrade: " & quotd.Get("sciencegrade"))
                        Log("Totalscore: " & quotd.Get("totalscore"))
                        Log("Totalgrade: " & quotd.Get("Totalgrade"))
                        Log("Division: " & quotd.Get("Division"))
                        Log("ire: " & quotd.Get("ire"))
                        Log("iregrade: " & quotd.Get("iregrade"))
                        Log("Years: " & quotd.Get("Years"))
                        Log("atk: " & quotd.Get("atk"))

                        'query =   "CREATE TABLE Academicspastv2 ( Names TEXT, Class TEXT, Stream TEXT, Expressed TEXT, sstscore Text, sstgrade TEXT, engscore Text,engrade Text,mathsscore Text,mathsgrade Text,sciencescore Text,sciencegrade Text,Totalscore Text,Totalgrade TEXT, id INTEGER )"
                        'SQL1.ExecNonQuery(query)
    
                        
                        'Starter.SQL1.ExecNonQuery("INSERT INTO Academics VALUES('" & quotd.Get("Names") & "','" & quotd.Get("class") & "','" & quotd.Get("Stream") & "','" & quotd.Get("Subject")  & "','" & quotd.Get("Total") & "','" & quotd.Get("Grade") & "','" & quotd.Get("Mid")  & "','" & quotd.Get("Ends") & "','" & quotd.Get("Term") & "','" & quotd.Get("Years") & "','" & quotd.Get("atk") & "')")
                        B4XPages.MainPage.SQL.ExecNonQuery2("INSERT INTO Academicspastv2 VALUES(?, ?, ?,?, ?, ?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?)", Array As Object(quotd.Get("Names"), quotd.Get("Class"), quotd.Get("Stream"),quotd.Get("Expressed"),quotd.Get("sstscore") ,quotd.Get("sstgrade"),quotd.Get("engscore"),quotd.Get("engrade"),quotd.Get("mathsscore"),quotd.Get("mathsgrade"),quotd.Get("sciencescore"),quotd.Get("sciencegrade"),quotd.Get("totalscore"),quotd.Get("Totalgrade"),quotd.Get("Division"),quotd.Get("ire"),quotd.Get("iregrade"),quotd.Get("Years"),quotd.Get("Account"),quotd.Get("atk")))
                    Next
            

                    'Return
                    'ProgressDialogShow2("Processing the Final data...",False)
                    Sleep(100)
                    ProgressDialogHide
                    'StartActivity(Archiveprimary)
                End If
            End If
        End If
    
        jt.Release
 

Brian Dean

Well-Known Member
Licensed User
Longtime User
i do not want the decimal values

Do you mean that you want to remove the decimal parts? If so you have two choices ...

B4X:
    Dim n As Double = 123.567
    Dim i As Int = Round(n)                    ' i = 124 (closest whole number to 123.567)
    Dim k As Int = Floor(n)                    ' k = 123 (nearest whole number less than 123.567)
 
Upvote 0
Top