Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Proper way of moving from Double to Integer
Message
De
08/02/2012 15:29:03
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01534895
Message ID:
01534904
Vues:
37
>I think it's always better to be explicit. In your case you will reply on implicit cast.

Here is the method:
        ' Return a numeric value
        ' If it is corrupted, we redirect to the main page
        ' expC1 HTLM form variable
        Public Function GetProcessNumeric(ByVal tcField As String) As Integer
            Dim lcPrimaryKey As String = ""
            Dim lnPrimaryKey As Integer = 0
            Dim lnPrimaryKeyTemp As Double = 0

            ' If the key exists
            If oProcess.IsProcess(tcField) Then
                
                ' Get the value
                lcPrimaryKey = oProcess.GetProcess(tcField)

                ' If we have a value
                If lcPrimaryKey.Length > 0 Then

                    ' If we have digit only
                    If oProcess.oApp.IsFilter09(lcPrimaryKey) Then

                        ' If we have less than 11 characters
                        If lcPrimaryKey.Length < 11 Then
                            lnPrimaryKeyTemp = Val(lcPrimaryKey)

                            ' If this is under or equal 2147483647
                            If lnPrimaryKeyTemp <= 2147483647 Then
                                lnPrimaryKey = lnPrimaryKeyTemp
                            Else
                                oProcess.RedirectMain(oProcess.cHttp)
                                Return 0
                            End If

                        Else
                            oProcess.RedirectMain(oProcess.cHttp)
                            Return 0
                        End If

                    Else
                        oProcess.RedirectMain(oProcess.cHttp)
                        Return 0
                    End If

                Else
                    oProcess.RedirectMain(oProcess.cHttp)
                    Return 0
                End If

            End If

            Return lnPrimaryKey
        End Function
I also like it like that as I can negotiate with it in any way I want and follows the path of the framework to not use too much of in-dept functionality of the .NET Framework as it makes it much difficult to migrate to another environment after.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform