Programming language used: C#.net
Using Dictionary Generics can save your day. In fact, this is an ideal method of storing data which has a key for identifying the row information.
Programming tips and topics for geeks. Keep calm and keep coding! :)
Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts
2015/03/09
2014/05/24
Exporting your data to excel in a much much easier way
When you're gonna
interact between your data within the database and MS Excel, you noticed that
it's kind of frustrating to do so. Because exporting the data to Excel is much
difficult if you are fond of doing projects that involves MS Excel. Well, I'm glad
to announce you there's a simple way to do so.
2014/04/19
Create your own Splash Screen Programmatically
Programming Language: C#

In this article, I’ll teach you on how to create your own Splash Screen.

In this article, I’ll teach you on how to create your own Splash Screen.
Changing icons of Desktop Application using Inheritance
Programming Language: C#
Tired of putting icon across many forms?
Tired of putting icon across many forms?
Labels:
C#,
coding,
dotnet,
Programming,
tutorial,
VisualStudio,
VS2010,
VS2013
Number to Sentence conversion
Programming Language: C#.net
Description: Write a program that convert the numbers into word sentence.
Ex. Input: 250 Output: Two-hundred and fifty
Solution: There are various solutions to solve this. But the hint is to write an algorithm which uses a string variable and concatenate it whenever the inputted number met certain requirements.
Things you need before starting:
- IDE(Visual Studio)
- Basic concept of OOP
- Basic knowledge of C# programming language
Today we’re going to play with numbers. If you wanted to convert numbers into sentence, if you're having problem with converting numbers into words this algorithm will solve it for you. This can also be useful in real-life scenario wherein you will create a program which will generate a cheque for the encoders like what I did within the office. So, let’s get started.
Just create a new console application within C#, and paste this method within your program:
//conversion of number to words constructor public static string NumberToWords(int number) { if (number == 0) return “zero”; if (number < 0) return “minus ” + NumberToWords(Math.Abs(number)); string words = “”; if ((number / 1000000) > 0) { words += NumberToWords(number / 1000000) + ” million “; number %= 1000000; } if ((number / 1000) > 0) { words += NumberToWords(number / 1000) + ” thousand “; number %= 1000; } if ((number / 100) > 0) { words += NumberToWords(number / 100) + ” hundred “; number %= 100; } if (number > 0) { if (words != “”) words += “and “; var unitsMap = new[] { “zero”, “one”, “two”, “three”, “four”, “five”, “six”, “seven”, “eight”, “nine”, “ten”, “eleven”, “twelve”, “thirteen”, “fourteen”, “fifteen”, “sixteen”, “seventeen”, “eighteen”, “nineteen” }; var tensMap = new[] { “zero”, “ten”, “twenty”, “thirty”, “forty”, “fifty”, “sixty”, “seventy”, “eighty”, “ninety” }; if (number < 20) words += unitsMap[number]; else { words += tensMap[number / 10]; if ((number % 10) > 0) words += “-” + unitsMap[number % 10]; } } return words; }
What about when the amount entered is a centavo?
This is a tricky one to solve. If you’re a programmer you will know what I mean. To solve this one, the key here is to scan the string inputted by the user and find the dot(.). Because, if there’s a dot in the value it will be considered a centavo value already. So I know you know what to do already but I’ll give you a code snippet on how I did it:
//paste this within Main Method string input = “”; bool isCentavo = false; string peso = “”; string centavo = “”; Console.Write(“Please input an amount: “); input = Console.ReadLine(); try //suppress errors due to outside bounds of array. You can fix it if you want { if (input.IndexOf(‘.’) != -1) { isCentavo = true; peso = input.Remove(input.IndexOf(‘.’)); for (int i = 0; i < 5; i++) { centavo += input[input.IndexOf('.') + i + 1]; //this code snippet will look for the centavo amount within the input. } } } catch (Exception) { }
And that’s it. You can now create a program which will convert number to words. Congratulations!
I’ve provided you a solution files so that you can see the source code. Download it here ->http://www.mediafire.com/download/whl2wk43bhvamcx/NumberToWords.7z
Labels:
C#,
coding,
dotnet,
Programming,
tutorial,
VisualStudio,
VS2010,
VS2013
2014/04/18
String Manipulation by detecting each character
Programming Language: C#.net
Need to manipulate or replace strings that matches the criteria? Or do you have a complex problem that involves a string of characters?
Need to manipulate or replace strings that matches the criteria? Or do you have a complex problem that involves a string of characters?
Labels:
C#,
coding,
dotnet,
Programming,
tutorial,
VisualStudio,
VS2010,
VS2013
Subscribe to:
Posts (Atom)