Go to Post The rules are the rules, but if the rules get so ridiculous some of us may choose not to play anymore and that is the bigger shame. - Paul Copioli [more]
Home
Go Back   Chief Delphi > Other > Chit-Chat
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 20-04-2010, 10:46
Carlee10's Avatar
Carlee10 Carlee10 is offline
Loves F.I.R.S.T.!!!!!!
FRC #1529 (CyberCards)
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Indiana
Posts: 580
Carlee10 is a splendid one to beholdCarlee10 is a splendid one to beholdCarlee10 is a splendid one to beholdCarlee10 is a splendid one to beholdCarlee10 is a splendid one to beholdCarlee10 is a splendid one to beholdCarlee10 is a splendid one to beholdCarlee10 is a splendid one to behold
Visual Basic?

I need some Visual Basic.Net help. Im using an older edition, and I didn't see anything in the programming, so I put it here.....feel free to move it. I have code for the project (Pig Latin Translator) I am working on if anyone thinks they might be able to fix/help it. Thanks.


/code/ ' Uses select case to determine vowels and consonants, and to translate text to
' pig latin.

Dim strInput As String = ""
Dim str1stCharacter As String = ""
Dim strOutput As String = ""
Dim intStringLength As Integer = 0
strInput = txtInput.Text
str1stCharacter = Microsoft.VisualBasic.Left(strInput, 1)
Select Case str1stCharacter.ToUpper()
Case "A", "E", "I", "O", "U"
strOutput = strInput & "WAY"
Case Else
intStringLength = Len(strInput)
strOutput = Microsoft.VisualBasic.Right(strInput, 3) & Microsoft.VisualBasic.Left(strInput, 2) & "AY"
End Select
MessageBox.Show("The Pig Latin Translation is: " & strOutput)
Exit Sub
/code/
__________________
Attending- College!
Awards: BMR's 2008 Judges Award
"Courage is not the absence of fear, but rather the judgment that something else is more important than fear. The brave may not live forever, but the cautious do not live at all."- Movie quote
Reply With Quote
  #2   Spotlight this post!  
Unread 20-04-2010, 12:45
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: Visual Basic?

We can probably help you, but it helps to know what's wrong with it/what it's not doing that it should/what's it's doing that it shouldn't.

--Ryan
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
Reply With Quote
  #3   Spotlight this post!  
Unread 20-04-2010, 20:02
EHaskins EHaskins is offline
Needs to change his user title.
AKA: Eric Haskins
no team (CARD #6 (SCOE))
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Elkhorn, WI USA
Posts: 998
EHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond repute
Send a message via MSN to EHaskins
Re: Visual Basic?

Here is the corrected code implemented in a console application.

Look at the comments for corrections.

Code:
Imports System.Text

Module Module1
    Sub Main()
        Do
            Dim input As String = Console.ReadLine
            If String.IsNullOrEmpty(input) Then
                Exit Sub
            End If
            Dim strOutput As String = GetPigLatin(input)
            Console.WriteLine(String.Format("The Pig Latin Translation is: {0}", strOutput))
        Loop
    End Sub

    Private Function GetPigLatin(ByVal input As String) As String
        Dim words As String() = input.Split(" ")
        Dim output As New StringBuilder() 'StringBuilder is much faster than regular string concatenation. 

        For Each word In words
            output.Append(GetPigLatinWord(word))
            output.Append(" ")
        Next
        Return output.ToString() 'Get the final string from the StringBuilder
    End Function

    Private Function GetPigLatinWord(ByVal strInput As String) As String
        Dim str1stCharacter As String = ""
        Dim strOutput As String = ""
        Dim intStringLength As Integer = 0
        str1stCharacter = Microsoft.VisualBasic.Left(strInput, 1)
        Select Case str1stCharacter.ToUpper()
            Case "A", "E", "I", "O", "U"
                strOutput = strInput & "WAY"
            Case Else
                'THIS IS WHAT I CHANGED. You were using fixed lengths to capture from each end of the word. 
                'That meant that only 5 char words would work with your implementation.
                strOutput = strInput.Substring(1) & strInput.Substring(0, 1) & "AY"
        End Select
        Return strOutput.ToLower 'makes output prettier
    End Function
End Module
__________________
Eric Haskins KC9JVH
Reply With Quote
  #4   Spotlight this post!  
Unread 21-04-2010, 17:55
Carlee10's Avatar
Carlee10 Carlee10 is offline
Loves F.I.R.S.T.!!!!!!
FRC #1529 (CyberCards)
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Indiana
Posts: 580
Carlee10 is a splendid one to beholdCarlee10 is a splendid one to beholdCarlee10 is a splendid one to beholdCarlee10 is a splendid one to beholdCarlee10 is a splendid one to beholdCarlee10 is a splendid one to beholdCarlee10 is a splendid one to beholdCarlee10 is a splendid one to behold
Re: Visual Basic?

Quote:
Originally Posted by RyanCahoon View Post
We can probably help you, but it helps to know what's wrong with it/what it's not doing that it should/what's it's doing that it shouldn't.

--Ryan
Oops. Its supposed to turn english text into pig latin, and then i have to calculate the number of words, the number of words starting with vowels, and percent of words that start with vowels,but i cant really get much to work. Like, if i type in "dog" i get "dog doay" instead of "ogday". but if i type in "aardvark" its correct and says "aardvarkway". Sorry for the confusion. And thank you EHaskins for the corrections. Ill have to check and fix mine tomorrow.
__________________
Attending- College!
Awards: BMR's 2008 Judges Award
"Courage is not the absence of fear, but rather the judgment that something else is more important than fear. The brave may not live forever, but the cautious do not live at all."- Movie quote
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic basicxman IT / Communications 11 13-11-2007 23:43
Custom Dashboard - Visual Basic Mike Lat Programming 3 23-01-2005 14:26
Visual Basic dddriveman Programming 12 20-03-2004 13:03
Visual Basic 6 Dashboard LBK Rules Programming 1 22-01-2003 13:06


All times are GMT -5. The time now is 00:06.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi