VB.NET 2013 - Reading and Writing Text Files

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 เม.ย. 2014
  • A video of an introduction in to text files (also known as sequential files) in VB.NET 2013. This video covers a number of functions and bits of theory to do with files. Reading from files, writing to files, checking if a file exists, learning about file extensions, appending to existing files and more.

ความคิดเห็น • 154

  • @petereells1246
    @petereells1246 4 ปีที่แล้ว +2

    Love this guy. Very simple - no BS - just code. I’ve been programming for 41 years and this is exactly what I need to get on my feet. I’ll bust programs into subroutines and design systems based upon my experience. UDEMY courses are good - but they teach you what they want you to know - not what you need to know. Thank you man. Love the Aussies.

  • @khadijanaheed8310
    @khadijanaheed8310 6 ปีที่แล้ว +11

    VERY VERY USEFUL! UNDERSTOOD THE WHOLE FILEHANDLING!!!!
    MAY GOD BLESS YOU! AMEN!

  • @billylutcher6945
    @billylutcher6945 4 ปีที่แล้ว

    Thank you so much. I starting to code in 2019. I lean qvery fast. Right now I'm making a game in Visual Basic. Without your video I would have given up on my game. Thank you so much and you are GOD.

  • @dennispeebles8910
    @dennispeebles8910 ปีที่แล้ว

    excellent demonstrations, I was having trouble trying to read/write some files to use and reuse in my programs for various subs/functions. thanks!!

  • @LuisCasanovaV
    @LuisCasanovaV 10 ปีที่แล้ว +2

    Just what I needed! Thank for taking the time to record / share this tutorial!

  • @DowzerWTP72
    @DowzerWTP72 9 ปีที่แล้ว +6

    Just *subscribed*. I've been looking for help like this for my AS levels, and your videos are perfect for what I am making! Thanks *so* much :)

  • @PatMcDonald41
    @PatMcDonald41 5 ปีที่แล้ว

    These tutorials are exceptional. Thank you.

  • @TheHelpGuy
    @TheHelpGuy 4 ปีที่แล้ว

    Just found this today, saved my life buddy. Thank you very much

  • @chrisraisin5587
    @chrisraisin5587 4 ปีที่แล้ว

    You are a very good teacher, Nicholas. Well done.

  • @luisfilipefilipe8211
    @luisfilipefilipe8211 7 ปีที่แล้ว +5

    the best vb tutos on TH-cam thanks

  • @fraserlangton8330
    @fraserlangton8330 7 ปีที่แล้ว +3

    mate you're a fucking legend, I didn't have a fucking shit stain of an idea what append did but you are my shining light in the darkness, you showed me the way. I will build temples for you and we will worship you for years to come.
    The night is dark and full of terrrors

  • @LorJayGmailcom
    @LorJayGmailcom 7 ปีที่แล้ว

    I am blessed to have found your videos...... Thank you

  • @finalflash98
    @finalflash98 7 ปีที่แล้ว

    THANK YOU SO MUCH SIR NICHOLAS DINGLE, I always thought filing was hard until I watched this video and managed to solve 3 to 4 tasks in my pre release exam paper for computer science 9608 ( keep up the good work!!!!!)

    • @NicholasDingle
      @NicholasDingle  7 ปีที่แล้ว +1

      Sounds awesome, hope you go well in the exam.

  • @HeshamALAhdal
    @HeshamALAhdal 8 ปีที่แล้ว

    Man i have to say thank you so so so much for this amazing tutorial, it is very understandable and you have amazing way to teach, good job and i wish you best .

    • @NicholasDingle
      @NicholasDingle  8 ปีที่แล้ว

      +Hesham AL-Ahdal (L.R.G) No worries, thanks mate!

  • @mpumelelomoyo3747
    @mpumelelomoyo3747 3 ปีที่แล้ว

    this is the best tutorial i found here on file handling

  • @chamodthalayarathna4326
    @chamodthalayarathna4326 3 ปีที่แล้ว

    Nice work. Very effective for my academics. Thank u.. keep doing like this.

  • @thwbn3993
    @thwbn3993 5 ปีที่แล้ว

    thank God I found your channel, dude!!!

  • @rajtechking
    @rajtechking 3 ปีที่แล้ว

    Really Great Video. You earned yourself a subscriber.

  • @ForeclosureGhost
    @ForeclosureGhost 2 ปีที่แล้ว

    Great video. Do you by chance have any videos about populating listviews from external text files in VB?

  • @jennamurdhen9818
    @jennamurdhen9818 9 ปีที่แล้ว

    thank you for this interesting tutorial...:)

  • @tomsvn7258
    @tomsvn7258 3 ปีที่แล้ว

    Thank you.. it help me so much .. thanks again

  • @elvisndobe3063
    @elvisndobe3063 5 ปีที่แล้ว

    thank you, good and easy to understand

  • @hassansaqib13
    @hassansaqib13 5 ปีที่แล้ว

    Thank you so much Sir!! Your video has been extremely helpful!!
    and yes..MOOOOOOOOOOOOOOO!!! coz why not!

  • @colinhegarty1065
    @colinhegarty1065 6 ปีที่แล้ว +8

    Hi, how do I get specific lines from the file?

  • @iwatchtechtutorials5236
    @iwatchtechtutorials5236 9 ปีที่แล้ว

    Thank you very much!

  • @Hagrona
    @Hagrona ปีที่แล้ว

    Thank you so much

  • @bymunako
    @bymunako 7 ปีที่แล้ว

    Hi Nicholas, may I please ask how I would go about loading data from a text file that has delimiters. All the information online is really complicated and I can't quite understand it! I have saved an array into a text file, separating the contents with commas and what to load it again to be displayed in VB. Thank you!

    • @NicholasDingle
      @NicholasDingle  7 ปีที่แล้ว

      I won't be able to write the code, but you'll be using LineInput() to get it line by line and then use .Split() on your strings to cut it up by commas.
      Give those functions a Google and you can find out.

  • @luigi8936
    @luigi8936 4 ปีที่แล้ว

    Hi NIck, that's a very interesting tutorial, it's really very helpful to me, but please i need to know how do i read only a specific number of items (say 120 items) from CSV file that has almost 800 items? Regards

  • @ruchikarathi3840
    @ruchikarathi3840 6 ปีที่แล้ว

    In the same way can we read excel files or csv files

  • @dragonboyjazz
    @dragonboyjazz 7 ปีที่แล้ว +1

    hahaha poo folder FTW, thanks for the tutorial, keep making vids, even if just updates of old tutorials showing new ways to do them, because its real bloody hard to find any good ones

  • @dongenfrank1990
    @dongenfrank1990 8 ปีที่แล้ว

    Thanks for the tutorial!
    I do have a small question... Which option do I have to select in the program to also get this 'suggestion/explanation message boxes' you get at for example 4.57

    • @NicholasDingle
      @NicholasDingle  8 ปีที่แล้ว

      When the parameter suggestion box comes up you can press the up and down arrow on the keyboard to see the options.

    • @dongenfrank1990
      @dongenfrank1990 8 ปีที่แล้ว

      Thank you for your reply, but it is actually this parameter suggestion box that I am curious about. when I write code is doesn't 'come up'.
      Do you know whether this is something you can turn on and off?

    • @NicholasDingle
      @NicholasDingle  8 ปีที่แล้ว

      +Frank van Dongen is this the problem? omegacoder.com/?p=1008

    • @dongenfrank1990
      @dongenfrank1990 8 ปีที่แล้ว

      Yes I think you're right. Maybe I've got a 'limited license' or something because I can't choose the first 4 options in Edit/Intellisense

    • @NicholasDingle
      @NicholasDingle  8 ปีที่แล้ว

      +Frank van Dongen odd. Have you got the community version? Also what version number are you running?

  • @urownplaylist
    @urownplaylist 5 ปีที่แล้ว

    Hi Nicholas, I have written program to create text file in the native folder in which my application installs(eg. c:/). I successfully generated setup file and i am able to install it but when i run it, it popups with "access to the is denied" message

  • @dasireddyrohitreddy3618
    @dasireddyrohitreddy3618 4 ปีที่แล้ว

    u have saved my life for the a level exam

  • @tonychen3316
    @tonychen3316 5 ปีที่แล้ว

    I have a stupid question, since I was a beginner, why the syntax in visual basic "Not equals to" is same as "equals to in the video?

  • @akhilteja9930
    @akhilteja9930 5 ปีที่แล้ว

    how the file properties were given?
    I am getting an error :-
    Error 1The name 'FileOpen' does not exist in the current context
    Error 2 The name 'FileOpen' does not exist in the current context

  • @KHALIDMEHMOOD-ww5xl
    @KHALIDMEHMOOD-ww5xl 7 ปีที่แล้ว

    excellent

  • @danieloyewole8526
    @danieloyewole8526 7 ปีที่แล้ว

    When using form and textboxes how would i get it that the username and password are stored on the same line but separated with a comma

    • @NicholasDingle
      @NicholasDingle  7 ปีที่แล้ว

      Read the text into a string and then check out the split function - www.dotnetperls.com/split-vbnet

  • @examinestudios2410
    @examinestudios2410 8 ปีที่แล้ว

    Could we use a try and catch error handling with finding if there is a file or not?

    • @NicholasDingle
      @NicholasDingle  8 ปีที่แล้ว

      +Examine Studios You can but it might just be easier to use the IO.File.Exists. Since the try and catch will find all errors

    • @georgegallimore6690
      @georgegallimore6690 8 ปีที่แล้ว

      +Nicholas Dingle did you get access to the link? also i need your help with this code.
      can you give me a function able code to run a bat file from the resource in vb.net using the special directory methods? i added a bat file to my app resource and using a lot of methods to call it but it's not working, what i am trying is to do is to program my app to start a .bat file in it's resource with special directory method so that the app can be able to run an any pc without have to search the c drive a path with the bat file location, the app is a keygen.

  • @TheOriginalNEG2013
    @TheOriginalNEG2013 7 ปีที่แล้ว

    How can I look for a specific part of a file and cut it and a few character after it out.

    • @NicholasDingle
      @NicholasDingle  7 ปีที่แล้ว

      Do you know the line number? If so, read that many lines and then use the SubString function.

  • @KS-xw3wj
    @KS-xw3wj 8 ปีที่แล้ว

    If i want to pass an object variable to a text file, but not delete the previous entries how would i do it.
    It is for a little log. so ill pass a date/log number from 0 to 600 and time

    • @NicholasDingle
      @NicholasDingle  8 ปีที่แล้ว

      What you're looking for is Append. Append works like Output, but doesn't delete the file's original contents.

    • @KS-xw3wj
      @KS-xw3wj 8 ปีที่แล้ว

      +Nicholas Dingle Thanks

  • @adnanshah3421
    @adnanshah3421 8 ปีที่แล้ว +3

    you are awesome , i never understood vb from my teachers but you :* . thanks for it . how do we close file to save it ?

  • @hackerpro6742
    @hackerpro6742 4 ปีที่แล้ว

    thanks bro

  • @londonnoods2765
    @londonnoods2765 6 ปีที่แล้ว +8

    After 1 Hour I found You Lol.

  • @Matthew.1994
    @Matthew.1994 6 ปีที่แล้ว

    i ahve a textbox where i write in a word. Lets say a write Hello in it.
    When i press the button i want the programm to check if the word hello
    is in the textfile. I have multiple words in the textfile. i ahve
    "hello" "bye" and "one" in it. How can i let the programm search for a
    match? btw the textfile is on dropbox

    • @NicholasDingle
      @NicholasDingle  6 ปีที่แล้ว

      This is a massive question really. You can use a function called IO.File.ReadAllLines("myfile.txt") which will pull all lines from a text file into a Array of Strings. You can then loop through the array and check if the words you need are in it. If you mean that you want to download the file from Dropbox prior to opening it you need to look at WebClient.DownloadFile("myfile.txt")

    • @ruzivogwata3575
      @ruzivogwata3575 5 ปีที่แล้ว

      Array, do a linear search. Hopefully it works

  • @stefanadrian5678
    @stefanadrian5678 8 ปีที่แล้ว

    Ty a lot !

  • @fr4nkie82
    @fr4nkie82 9 ปีที่แล้ว +1

    Hey, would it be possible to email you something that i am trying to make with vb? its been awhile since i used it and i do need some help

  • @ImSyed109
    @ImSyed109 7 ปีที่แล้ว

    is it necessary to add ToUpper with input? what does it do?

    • @NicholasDingle
      @NicholasDingle  7 ปีที่แล้ว +1

      I'll admit it's been a long while since I made this video and I forget where I used the ToUpper function. But ToUpper is good to convert characters in a string into all uppercase letters. Then it's easy to compare strings using if statements.

    • @ImSyed109
      @ImSyed109 7 ปีที่แล้ว

      Nicholas Dingle ok great thanks

  • @vincedelima7515
    @vincedelima7515 8 ปีที่แล้ว

    nice tut

  • @nicholastrivella7966
    @nicholastrivella7966 7 ปีที่แล้ว +3

    Awsome tutorial. I have been struggling to find any vb console tutorials on how to import information from a CSV file into a 2D array. would you mind making one?

    • @NicholasDingle
      @NicholasDingle  7 ปีที่แล้ว +1

      That's a great idea, I'll add it to my video ideas.

    • @georgegallimore6690
      @georgegallimore6690 7 ปีที่แล้ว

      hey friend! remember me?

    • @NicholasDingle
      @NicholasDingle  7 ปีที่แล้ว

      +george gallimore sure do

    • @georgegallimore6690
      @georgegallimore6690 7 ปีที่แล้ว

      great! it's simple favor, i would like for you to edit. i have this screen capture code which i am trying to get it to save the screenshots with the same file name without over writing the other, egs screenshot1, screenshot2, screenshot3 all in the same folder with the same filename but count with 1 at the end.
      here is the code:
      If Not Directory.Exists(ScShot & "\ScreenCapture") Then
      Directory.CreateDirectory(ScShot & "\ScreenCapture")
      End If
      If Directory.Exists(ScShot & "\ScreenCapture") Then
      Try
      Dim screenshot1 As Bitmap
      Dim graph1 As Graphics
      screenshot1 = New Bitmap(Screen.PrimaryScreen.Bounds.Size.Width, Screen.PrimaryScreen.Bounds.Size.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
      graph1 = Graphics.FromImage(screenshot1)
      graph1.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy)
      Dim path As String = ("C:\Users\" & Convert.ToString(Guid.NewGuid()) & "\Documents\ScreenCapture\Screenshot" & ".png")
      screenshot1.Save("C:\Users\" & SystemInformation.UserName & "\Documents\ScreenCapture\Screenshot" & ".png", System.Drawing.Imaging.ImageFormat.Png)
      'Timer2.Start()
      Timer1.Stop()
      Catch error_q As Exception
      MsgBox(error_q.ToString)
      End Try
      End If

    • @NicholasDingle
      @NicholasDingle  7 ปีที่แล้ว

      That's not too bad, just use a while loop with a counter. Check if the file exists, if it does move to the next number and check again. Also note below I use SpecialDirectories to get the My Documents folder.
      Dim fileCounter As Integer = 1
      While IO.File.Exists(My.Computer.FileSystem.SpecialDirectories.MyDocuments &
      "\ScreenCapture\Screenshot" & fileCounter & ".png")
      fileCounter += 1
      End While

  • @eplays9419
    @eplays9419 9 ปีที่แล้ว

    How would I add text to a specific line, without deleting whats on line 2

  • @bishallamichhane811
    @bishallamichhane811 7 ปีที่แล้ว

    hey there. Love your videos and thanks a lot.Can you make a video for random files? That would be so good of you.

    • @NicholasDingle
      @NicholasDingle  7 ปีที่แล้ว

      I might end up doing this for C# but VB won't really get much attention from me in the future.

    • @bishallamichhane811
      @bishallamichhane811 7 ปีที่แล้ว

      thank you for your response..

  • @shaniasooranna7351
    @shaniasooranna7351 8 ปีที่แล้ว

    I've followed all the steps in your video :/ and there's no hello.txt which has been created

  • @shaniasooranna7351
    @shaniasooranna7351 8 ปีที่แล้ว

    I've created the ''hello.txt'' but i cannot find it on my computer .Why ?

    • @NicholasDingle
      @NicholasDingle  8 ปีที่แล้ว

      +Shania Sooranna If you created the file in VB.NET with just the filename "hello.txt" then it should be inside your Debug folder, which you'll find "Project Folder\bin\Debug"

  • @seyhakhiev1496
    @seyhakhiev1496 6 ปีที่แล้ว

    thank

  • @heavenmashingaidze6488
    @heavenmashingaidze6488 4 ปีที่แล้ว

    can you please show me how to connect access database to a console app in vb.net please please

  • @AtomicNotes
    @AtomicNotes 3 ปีที่แล้ว

    I called my extension a ds file (for my programming language DylanScript :D)

  • @diyencurpen2424
    @diyencurpen2424 4 ปีที่แล้ว

    what does .toUpper does

  • @Brewermb
    @Brewermb 5 ปีที่แล้ว

    I think VB.Net closes open files when you end the program, if you had left it running you would have got an error.

  • @khairi_salleh466
    @khairi_salleh466 9 ปีที่แล้ว

    hello nicholas.my name is khairi and im from malaysia. i would like to ask you on how to make a vb program. there are 1000line of data in notepad. then user want to devide the 1000 line into whatever number their like using vb
    hope u can help me

    • @NicholasDingle
      @NicholasDingle  9 ปีที่แล้ว

      Hi mate do you want to email me your idea with a bit more detail? I'd love to help out, right now I'm not quite sure what you would like to do.

    • @khairi_salleh466
      @khairi_salleh466 9 ปีที่แล้ว

      hi mate. I already pm you at hangout
      do still using hangout?

    • @NicholasDingle
      @NicholasDingle  9 ปีที่แล้ว

      Khairi Salleh Not really. Do you want to email me an example text file you might be using in your application?

  • @izaansaquib6465
    @izaansaquib6465 7 ปีที่แล้ว

    why did u not simply write If input.ToUpper = ''STOP'' Then PrintLine(1, input) at 14:07 instead of ''STOP'' ps iam new at programing

  • @wasifnaeem6672
    @wasifnaeem6672 7 ปีที่แล้ว

    Hello there Sir, I was wondering if you could help me out with accessing the binary files in random mode, i already know the method to access the file using Stream method but i am not able to do it by FileOpen method.. BTW.. You Rock..

    • @NicholasDingle
      @NicholasDingle  7 ปีที่แล้ว +1

      You can't actually use FileOpen and Stream at the same time. They are different generations of technology. I'm almost certain that under the hood, FileOpen would be using Streams.
      Depending on what you want to do I would go down the Stream method or using the File.ReadAllText methods. Hope I helped you there.

    • @wasifnaeem6672
      @wasifnaeem6672 7 ปีที่แล้ว

      Thanks for your quick reply.. I just want to put data into file and use Hash function to calculate the record starting position.. and read from the same position..e.g
      file.position = hash(thisfile.name)
      i amm not familier with ReadAllText method.. can you suggest any good book for console programming?

  • @georgegallimore6690
    @georgegallimore6690 8 ปีที่แล้ว

    hey nicholas, i have a two solution project. in solution two, i have classes and module that i want to used in solution one
    but the two project is not linking. when i am in solution two all the class and modules show up in the toolbox but in solution one it's not. what do you think i am missing out?

    • @NicholasDingle
      @NicholasDingle  8 ปีที่แล้ว

      I'll assume you have two projects in one solution and that project two contains code for project one. You need to open My Project for project one and go to references. Add project two in there. After that down the bottom, tick the name of project two and you're good to go

    • @georgegallimore6690
      @georgegallimore6690 8 ปีที่แล้ว

      here is the project mega.nz/#!1gdDAbob

    • @NicholasDingle
      @NicholasDingle  8 ปีที่แล้ว

      Link says I need a decryption key

    • @georgegallimore6690
      @georgegallimore6690 8 ปีที่แล้ว

      +Nicholas Dingle here's my new link:
      drive.google.com/open?id=0B-K3TTJgHgWXbmxSbEVDYk1FUGc
      just right click and download the NHunspell project

    • @georgegallimore6690
      @georgegallimore6690 8 ปีที่แล้ว

      hey friend, did get the project?

  • @qaisarnawaz7236
    @qaisarnawaz7236 5 ปีที่แล้ว

    Dude, you're funny :)

  • @Duarte1298
    @Duarte1298 3 ปีที่แล้ว +1

    Part 2: 16:12 :) you're welcome

  • @minsoobae6458
    @minsoobae6458 3 ปีที่แล้ว

    Console.WriteLine("ALL HAIL NICHOLAS DINGLE!! OUR SAVIOUR!!")

  • @AtomicNotes
    @AtomicNotes 3 ปีที่แล้ว

    Great video but Windows defender is SO stupid and it blocked my program from creating the file :(

  • @cbzmemes5297
    @cbzmemes5297 4 ปีที่แล้ว

    Numba

  • @louismilan4612
    @louismilan4612 6 ปีที่แล้ว

    love this video. please marry me

  • @MSMVoid
    @MSMVoid 3 ปีที่แล้ว

    Sorry but didn’t find this helpful

  • @luigi8936
    @luigi8936 4 ปีที่แล้ว

    Hi NIck, that's a very interesting tutorial, it's really very helpful to me, but please i need to know how do i read only a specific number of items (say 120 items) from CSV file that has almost 800 items? Regards