Visual Basic Tutorial - 21 - Formatting Strings

  Рет қаралды 79,400

thenewboston

thenewboston

Күн бұрын

Пікірлер: 39
@w.b.r.6332
@w.b.r.6332 10 жыл бұрын
Just wanted to say thanks Sam for all of these awesome tutorials.
@DigitalMonsters
@DigitalMonsters 11 жыл бұрын
Blitzing through these ^^ will have 200 done in a few days at this pace
@HikikomoriDev
@HikikomoriDev 11 жыл бұрын
The Easy tutorials allow people who have no idea what the computing world may be are just getting out of the shell for the first time. You could always try more stuff like extreme Java and complex databases. but please always remember there will be people who have no idea where they are going, and this is their solution. there is also solutions for you, please search advanced programming.
@ImperialPlanet
@ImperialPlanet 10 жыл бұрын
It actually rounds the decimals in the number you have stated.
@23Drezzy
@23Drezzy 12 жыл бұрын
Thank you. I was just about to ask if it rounds off OR truncates values.
@chanwookim8263
@chanwookim8263 11 жыл бұрын
Excellent tutorial once again. Keep up the good work
@Jbergawane9
@Jbergawane9 6 жыл бұрын
Thank you so much, but what is the difference between rounding and string formating ?
@jasonmesa4224
@jasonmesa4224 7 жыл бұрын
I can't get (String.Format("{0:n2}", myDouble)) to work in VB 2015 using buttons or other referenced portions. Cant use console.writeline for everything...
@robertmccully2792
@robertmccully2792 7 жыл бұрын
Here are there variations using window forms. They all work vb 2010 2015 is a memory hog... Dim dblNumber As Double dblNumber = 12.123456789 dblNumber /= 7 MessageBox.Show(String.Format("{0:n2}", dblNumber) & "HI..", "hello") MessageBox.Show(String.Format("Test..." & "{0:n9}", dblNumber), "Floating Numbers") MessageBox.Show("test.." & String.Format("{0:n5}", dblNumber)) Close()
@thishitscustom333
@thishitscustom333 13 жыл бұрын
@onlivegamer For Console.WriteLine(String.Format("{0:n2}", myDouble))....... How can you format a string (which are letters) with {0:n2}? I understand what {0,n2} does but if you want to format a number shouldn't the statement be (myDouble.Format("{0:n2}", myDouble)) ? If myDouble is as double, why do you write String? Thanks
@arsenalprince4
@arsenalprince4 12 жыл бұрын
@bomer890 I don't know if this is a late reply and I am still a beginner. What I suppose the String.format does is not to alter the number's format, but only display it as a string which has the format{0:n2}, myDouble is unchanged.
@TDawg-de8sb
@TDawg-de8sb 8 жыл бұрын
its so funny looked at vb a week ago expecting it to be really hard its not that complicated because all the syntax and stuff are easy to pick up on I love vb
@greatbucket85
@greatbucket85 12 жыл бұрын
Hi Sam, please assist me with line number 9. I have followed it to the detail and didn't receive anything on the error list. however once I start debugging. an error exception occurs.
@bradmillington5569
@bradmillington5569 4 жыл бұрын
Any chance you remember how you fixed this 7 years on? 😅
@TheVerbalAxiom
@TheVerbalAxiom 10 жыл бұрын
2nd day of Vb.net, Time for my 22nd tutorial, on top of already creating side projects. #GettingStronger
@bomer890
@bomer890 13 жыл бұрын
Hey..i'm not really know about the .format('{0.n2}'; myDouble).... can somebody explan to me...??
@DailyFrankPeter
@DailyFrankPeter 10 жыл бұрын
I get an InvalidCastException in line 7
@muazabdool6047
@muazabdool6047 10 жыл бұрын
Probably because of you used . instead of , i know its annoying :) also had the same problem
@newhuman9458
@newhuman9458 9 жыл бұрын
تحية لكل عربي لم يفهم ههههههههه
@23Drezzy
@23Drezzy 12 жыл бұрын
I might be late but once you type "String." it uses the string class in .NET to convert the values given to string format. I am not 100% sure though.
@harishli2020
@harishli2020 12 жыл бұрын
I have exactly done what you have shown, but when I type 2142.2342, I'm getting 21.422.342,00.
@RahilWazirAli
@RahilWazirAli 12 жыл бұрын
No!!! In the 19th tutorial he didn't forget :D
@spyroglitcher
@spyroglitcher 13 жыл бұрын
@deenotheman2 thats right.
@VijayNandwani
@VijayNandwani 13 жыл бұрын
You didn't explain what is the use and function of String.Format("{0:n2}"
@FonteneleNXT
@FonteneleNXT 12 жыл бұрын
I think it coud be useful for a calculator program.
@Blackllama13
@Blackllama13 13 жыл бұрын
Keep in mind, it rounds to the first .2 deciaml points. so if I did 15.666 i'd come out as 15.67
@greatbucket85
@greatbucket85 11 жыл бұрын
Right, anyway I figured it out. Thanks
@mattablack23
@mattablack23 8 жыл бұрын
This is me being late to the game but this uses what we have learned from a few previous lessons up to now.. Module Module1 'rapping up from tutorial 19 to 21... Tutorials by Sam AKA TheNewBoston.. AKA OnliveGamer.. Sub Main() Dim myString As String = Nothing Dim dValue As Double = Nothing Console.WriteLine("Please enter a set of letters or a word that equals up to 5 characters or more.") myString = Console.ReadLine() If myString.Length >= 5 Then 'I sat here for like 10 minutes wondering why mystring.length.Equals(5) did not work when I 'typed because I never typed exactly five letters.. Console.WriteLine("Please enter a decimal value") dValue = Console.ReadLine() Console.Clear() Console.WriteLine(String.Format("{0:n2}", dValue)) Console.WriteLine(myString.ToUpper()) Console.WriteLine(myString.ToLower()) Console.ReadLine() Console.WriteLine(myString.Substring(0, 1)) Console.WriteLine(myString.Substring(0, 2)) Console.WriteLine(myString.Substring(0, 3)) Console.WriteLine(myString.Substring(0, 4)) Console.WriteLine(myString.Substring(0, 4)) Console.WriteLine(myString.Substring(0, 3)) Console.WriteLine(myString.Substring(0, 2)) Console.WriteLine(myString.Substring(0, 1)) Console.WriteLine(myString.Substring(0)) Console.ReadLine() Else Console.Clear() Console.WriteLine("The string must be at least 5 letters long.") Console.ReadLine() End If End Sub End Module
@davidebettina2792
@davidebettina2792 6 жыл бұрын
go ahead
@voltaquake
@voltaquake 13 жыл бұрын
hehe
@ben1996123
@ben1996123 13 жыл бұрын
haha
@VijayNandwani
@VijayNandwani 13 жыл бұрын
:D
@Sajib115
@Sajib115 11 жыл бұрын
You are.
@spyko94
@spyko94 11 жыл бұрын
Yeah sure dude, I'm the stupid one here.
@XModding7
@XModding7 11 жыл бұрын
You are....
@jared0801
@jared0801 13 жыл бұрын
hehe
Visual Basic Tutorial - 22 - Replacing SubStrings
4:20
thenewboston
Рет қаралды 57 М.
Visual Basic Tutorial - 15 - Nested If Statements
6:01
thenewboston
Рет қаралды 108 М.
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
Visual Basic Tutorial - 17 - Logical Operators
6:32
thenewboston
Рет қаралды 93 М.
Visual Basic Tutorial - 20 - SubStrings
4:24
thenewboston
Рет қаралды 76 М.
Communicating between processes (using pipes) in C
14:00
CodeVault
Рет қаралды 290 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 842 М.
2,000 People Fight For $5,000,000
24:45
MrBeast
Рет қаралды 52 МЛН
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 899 М.
چطور کارهای‌مان را به تعویق نیاندازیم؟
16:37
Visual Basic.NET Programming. Beginner Lesson 1. Hello Visual Studio
13:04
Computer Science Lessons
Рет қаралды 485 М.
The Art of Code - Dylan Beattie
1:00:49
NDC Conferences
Рет қаралды 4,7 МЛН
Visual Basic Tutorial - 11 - Getting User Input
6:46
thenewboston
Рет қаралды 179 М.