Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Good Integer

Posted on April 11, 2013October 24, 2021 By David Kittell
protected int nGoodInt (string sNumber)
		{
		sNumber = sNumber.Trim();
		int Num;
		bool isNum = int.TryParse(sNumber, out Num);
		if (isNum)
			{
			return Num;
			}
		else
			{
			return 0;
			}
		}
protected System.Boolean IsNumeric(System.Object Expression)
	{
		if (Expression == null || Expression is DateTime)
		{
			return false;
		}

		if (Expression is Int16 || Expression is Int32 || Expression is Int64 || Expression is Decimal || Expression is Single || Expression is Double || Expression is Boolean)
		{
			return true;
		}

		try
		{
			if (Expression is string)
			{
				Double.Parse(Expression as string);
				return false;
			}
			else
			{
				Double.Parse(Expression.ToString());
				return true;
			}
		}
		catch
		{
			return false;
		}
	}
Function GoodInt(s)
	' Returns a "good" number, accounting for null values, etc.
	On Error Resume Next
	If len(s) > 0 and isNumeric(s) then
		s = csng(s)
		GoodInt= CLng(s)
	Else
		GoodInt= 0
	End If
	If Err Then GoodInt= 0
End Function
Function String Value
GoodInt 55 55
GoodInt 55.55 56
GoodInt 55.45 55
GoodInt SomeText 0
Originally Posted on April 11, 2013
Last Updated on October 24, 2021
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

ASP C# ASPX Code CSharp VB good intgood numbergoodintgoodnumgoodnumber

Post navigation

Previous post
Next post

Related Posts

Read Text File Content With Try Catch

Posted on September 18, 2013October 26, 2015

Imports System.IO public class Test public Shared Sub Main Dim srReader As IO.StreamReader Dim strLine As String Dim blnDone As Boolean = False Dim strFileName As String = "test.txt" ‘Read text from a file and display it in a list box. srReader = New IO.StreamReader(strFileName) Try While Not blnDone strLine…

Read More

Raspberry Pi – Install Firefox and Thunderbird on Raspbian

Posted on April 9, 2018

sudo apt install dirmngr echo "deb http://ppa.launchpad.net/ubuntu-mozilla-security/ppa/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/firefox.list echo "deb-src http://ppa.launchpad.net/ubuntu-mozilla-security/ppa/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/firefox-source.list echo "deb http://ppa.launchpad.net/mozillateam/thunderbird-next/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/thunderbird.list echo "deb-src http://ppa.launchpad.net/mozillateam/thunderbird-next/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/thunderbird-source.list sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys A6DCF7707EBC211F sudo apt-key adv…

Read More

MSSQL Server Information

Posted on August 27, 2015May 13, 2016

If you have ever started a new job and we told to “Dig into the database and learn” these scripts likely have come to mind whether or not you knew/know them. SELECT @@Servername AS [Server Name] –,@@ServiceName AS [Service Instance] ,Name AS [Database Name] ,create_date AS [Service Started] ,DATEDIFF(s, create_date,…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes