kcorj2244's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
15 (0.02 per day)
Joined:
29-January 13
Profile Views:
416
Last Active:
User is offline May 06 2014 03:45 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   kcorj2244 has not set their status

Posts I've Made

  1. In Topic: Having Trouble with Pig Latin to English Translator

    Posted 4 Mar 2013

    View PostIronRazer, on 04 March 2013 - 02:10 PM, said:

    The example by Norman_Bates is not working rite but, it may just need some tweeking. If you put in (Chair) as the word it gives you (hairch ay) not (air-chay). Here is an example i did but, it does not use (Case) it uses (if else) maybe you can use some of it to fix your program.
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If TextBox1.Text <> "" Then
                Dim english As String = TextBox1.Text
                Dim cnt As Integer = 0
                Dim tststr As String = "AEIOUY1234567890"
    
                For x = 0 To english.Length - 1
                    If tststr.Contains(english.Substring(x, 1).ToUpper) Then Exit For
                    cnt += 1
                Next
    
                If cnt < english.Length And cnt > 0 Then
                    Dim str1 As String = english.Remove(cnt)
                    Label1.Text = english.Substring(cnt) & "-" & str1 & "ay"
                Else
                    Label1.Text = english & "-Way"
                End If
            End If
        End Sub
    
    


    Thanks! I have to ask though, what is this block of code doing?

                For x = 0 To english.Length - 1
                    If tststr.Contains(english.Substring(x, 1).ToUpper) Then Exit For
                    cnt += 1
                Next
    
    


    From what I can see it assigns x = 0 to whateverisentered.length -1

    If that just getting the length of whatever I enter?

    How do I edit a post lol?

    That line of code finds out where in the string the first vowel is correct, and then stores that number in the counter???
  2. In Topic: Read text file, and assign content to a variable

    Posted 3 Feb 2013

    View Postandrewsw, on 03 February 2013 - 12:39 PM, said:

    readAllText returns a string so you should declare readFile as a string.



    Remember that program I was working on? I have this so far for the read file


    
            Dim inputData As String
            inputData = InputBox("Enter what to save to the text file")
    
            Dim FILE_NAME As String = "C:\Users\Ben\Documents\Vb.netshiz\" & TextBox1.Text.Replace("\", "").Replace(".txt", "") & ".txt"
    
            If TextBox1.Text = String.Empty Then
    
                Dim defaultReader As String
    
                defaultReader = IO.File.ReadAllText("C:\Users\Ben\Documents\Vb.netshiz\default.txt")
    
                Dim default_name As String
    
                default_name = defaultReader
    
                Dim defaultLocation As String
    
                defaultLocation = "C:\Users\Ben\Documents\Vb.netshiz\" & default_name.Replace("\", "").Replace(".txt", "") & ".txt"
    
                FILE_NAME = defaultLocation
    
            End If
    
    
    


    I'm trying change the file location to w/e the name is in the text file, but after it goes through all that code, it doesn't continue to the other code where it writes w/e is in the input box to the file... Help please :)
  3. In Topic: Read text file, and assign content to a variable

    Posted 3 Feb 2013

    View Postmodi123_1, on 03 February 2013 - 12:29 PM, said:

    If you are reading it would be 'stream reader', right?

    http://msdn.microsof...reamreader.aspx



    Yeah, this is my code so far


            Dim default_name = "C:\Users\Ben\Documents\Vb.netshiz\default.txt"
    
            Dim readFile As IO.StreamReader
    
            readFile = IO.File.ReadAllText(default_name)
    
    


    the line readFile = Io.File.ReadAllText(default_name) gives me a convert string error.

    Dim default_name as string*
  4. In Topic: Create new line when writing to a txt file

    Posted 3 Feb 2013

    View Postandrewsw, on 03 February 2013 - 11:10 AM, said:

    FYI you can add a default to the InputBox:

    inputData = InputBox("Enter what to save", "learninggoal")
    

    Rather than hard-coding the path to your Documents folder you can construct it with:
    sFileName = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) _ 
        & System.IO.Path.DirectorySeparatorChar & "somefile.txt"
    

    where the path-separator on Windows is "\". This is a more flexible approach.

    You can insert your subfolder as well:

    sFileName = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) _ 
        & System.IO.Path.DirectorySeparatorChar & "Vb.netshiz" _
        & System.IO.Path.DirectorSeparatorChar & "somefile.txt"
    


    Thanks! I left one of my questions in the code xD, so, how do I stop the rest of the code being executed after this If statement:

    If TextBox1.Text = String.Empty Then
                    FILE_NAME = "C:\Users\Ben\Documents\Vb.netshiz\learninggoal.txt"
    
                    writeFile = IO.File.CreateText(FILE_NAME) 'Creates a new file
                    writeFile.WriteLine(inputData)
                    writeFile.Close()
    
                End If
    
    
  5. In Topic: Create new line when writing to a txt file

    Posted 3 Feb 2013

    View PostLilGhost, on 03 February 2013 - 10:55 AM, said:

    View Postkcorj2244, on 03 February 2013 - 10:45 AM, said:

    View PostLilGhost, on 02 February 2013 - 07:34 PM, said:

    when you go to write to the document say:

    FILE_NAME = "C:\Users\Ben\Documents\Vb.netshiz\" & TextBox1.text.replace("\", "").replace(".txt", "") & ".txt"
    
    


    and then continue with your saving stuff. Or, if you'd like to get the filename with an input box say something like:
    Dim saveSpot as string = inputbox("What should the file name be?")
    FILE_NAME = "C:\Users\Ben\Documents\Vb.netshiz\" & saveSpot.replace("\", "").replace(".txt", "") & ".txt"
    
    


    Ok, I have another question to add.

    Here is my current code

            Dim inputData As String
    
    
            inputData = InputBox("Enter what to save")
    
            Dim FILE_NAME As String = "C:\Users\Ben\Documents\Vb.netshiz\" & TextBox1.Text.Replace("\", "").Replace(".txt", "") & ".txt"
    
    
    
            If System.IO.File.Exists(FILE_NAME) = True Then
    
                Dim objWriter As New System.IO.StreamWriter(FILE_NAME, IO.FileMode.Append)
    
                objWriter.WriteLine(inputData)
                objWriter.Close()
                MsgBox("Text written to file")
    
    
    
            Else
    
                MsgBox("File Does Not Exist, being created now")
    
                FILE_NAME = "C:\Users\Ben\Documents\Vb.netshiz\" & TextBox1.Text.Replace("\", "").Replace(".txt", "") & ".txt"
    
                Dim writeFile As IO.StreamWriter
                writeFile = IO.File.CreateText(FILE_NAME) 'Creates a new file
                writeFile.WriteLine(inputData)
                writeFile.Close()
    
    
    
            End If
    
    


    So right now, the file that it saves to has to be specified in the textbox. For example, if you would like to create a new file you would put w/e you wanted in the text box, but if you wanted to save to an existing file, you would have to specify the existing file name minus the extension. So, my question is how do I create a default file name, that it will create/write to, if the text box is empty? What is the code to see if the textbox is empty?

    Thanks


    Dim inputData As String
            inputData = InputBox("Enter what to save")
    
    If Textbox1.text <> "" Then
    
            Dim FILE_NAME As String = "C:\Users\Ben\Documents\Vb.netshiz\" & TextBox1.Text.Replace("\", "").Replace(".txt", "") & ".txt"
    
    Else
    Dim FILE_NAME As String = "C:\Users\Ben\Documents\Vb.netshiz\DefaultSaveSpot.txt"
    End If
    
            If System.IO.File.Exists(FILE_NAME) = True Then
    
                Dim objWriter As New System.IO.StreamWriter(FILE_NAME, IO.FileMode.Append)
    
                objWriter.WriteLine(inputData)
                objWriter.Close()
                MsgBox("Text written to file")
    
    
    
            Else
    
                MsgBox("File Does Not Exist, being created now")
    
                FILE_NAME = "C:\Users\Ben\Documents\Vb.netshiz\" & TextBox1.Text.Replace("\", "").Replace(".txt", "") & ".txt"
    
                Dim writeFile As IO.StreamWriter
                writeFile = IO.File.CreateText(FILE_NAME) 'Creates a new file
                writeFile.WriteLine(inputData)
                writeFile.Close()
    
    
    
            End If
    
    


    or you can simply move around that if statement so it gives them an error message and doesn't execute any code (besides the error message) when the textbox1.text element = "" (empty string).



    So this is my code right now, it's basically finished

            Dim inputData As String
    
    
            inputData = InputBox("Enter what to save")
    
            Dim FILE_NAME As String = "C:\Users\Ben\Documents\Vb.netshiz\" & TextBox1.Text.Replace("\", "").Replace(".txt", "") & ".txt"
    
            If TextBox1.Text = String.Empty Then
                FILE_NAME = "C:\Users\Ben\Documents\Vb.netshiz\learninggoal.txt"
            End If
    
            If System.IO.File.Exists(FILE_NAME) = True Then
    
                Dim objWriter As New System.IO.StreamWriter(FILE_NAME, IO.FileMode.Append)
    
                objWriter.WriteLine(inputData)
                objWriter.Close()
                MsgBox("Text written to file")
    
    
    
            Else
    
                Dim writeFile As IO.StreamWriter
    
                If TextBox1.Text = String.Empty Then
                    FILE_NAME = "C:\Users\Ben\Documents\Vb.netshiz\learninggoal.txt"
    
                    writeFile = IO.File.CreateText(FILE_NAME) 'Creates a new file
                    writeFile.WriteLine(inputData)
                    writeFile.Close()
    
                End If
    
                MsgBox("File Does Not Exist, being created now")
    
                FILE_NAME = "C:\Users\Ben\Documents\Vb.netshiz\" & TextBox1.Text.Replace("\", "").Replace(".txt", "") & ".txt"
    
    
                writeFile = IO.File.CreateText(FILE_NAME) 'Creates a new file
                writeFile.WriteLine(inputData)
                writeFile.Close()
    
    
    
            End If
    [code]
    
    The only thing I need is that if the textbox is empty as seen here, I want it to stop all the code after that. What do I use? I tried end but that closes my program. How do I stop the code from being executed after that if statement, if that if statement is infact used (ie: the textbox is empty)
    
    [code]
    If TextBox1.Text = String.Empty Then
                    FILE_NAME = "C:\Users\Ben\Documents\Vb.netshiz\learninggoal.txt"
    
                    writeFile = IO.File.CreateText(FILE_NAME) 'Creates a new file
                    writeFile.WriteLine(inputData)
                    writeFile.Close()
    
                End If
    
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

kcorj2244 hasn't added any friends yet.

Comments

kcorj2244 has no profile comments yet. Why not say hello?