04-17-2011, 03:53 AM
(This post was last modified: 04-17-2011, 04:55 AM by AceInfinity.)
I would have used
Or maybe:
Those are the 2 I thought of
UPDATE:
Haha, I created a code that worked, I added:
Update: I also made it so that "A" is the only single character you can input into the original text field to translate since it's the only singular letter word in the english language.
"A" to PigLatin in my application will translate to: "a-way"
and if you select "A" to translate to english it will translate to: "A"
I'm going to update my download link soon... I worked for a while on such a useless app lol![Smile Smile](https://www.supportforums.net/images/smilies/smile.gif)
Direct Download:
Pig Latin Translator v1.0
Full Source:
I noticed that it wasn't about anything other than getting people participating in the coding. But I noticed that both of you kept the same default icon for your project and other basic things like that. Always good practice to get into setting up your project though.
Code:
If Textbox1.Text.Trim = 0 Then
Or maybe:
Code:
If Textbox1.Text.StartsWith(" ") Then
Those are the 2 I thought of
UPDATE:
Haha, I created a code that worked, I added:
Code:
If TextBox1.Text.Trim.Length = 0 Then
MsgBox("You must type something into the input textbox field in order to translate.", MsgBoxStyle.Critical, "Error - PigLatin Translator v1.0")
Exit Sub
End If
Update: I also made it so that "A" is the only single character you can input into the original text field to translate since it's the only singular letter word in the english language.
Code:
ElseIf TextBox1.Text = "a" Then
TextBox2.Text = "a-way"
ElseIf TextBox1.Text.Length = 1 Then
MsgBox("There was an error while trying to translate the input text. Please try again or make sure you spelled it correctly", MsgBoxStyle.Critical, "Error - PigLatin Translator v1.0")
Exit Sub
End If
"A" to PigLatin in my application will translate to: "a-way"
and if you select "A" to translate to english it will translate to: "A"
I'm going to update my download link soon... I worked for a while on such a useless app lol
![Smile Smile](https://www.supportforums.net/images/smilies/smile.gif)
Direct Download:
Pig Latin Translator v1.0
Full Source:
Code:
Public Class Form1
'Checks to whether or not you want your form topmost property active or not. Your window will appear above all others if it is checked
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
'If Checkbox is checked then topmost is active
If CheckBox1.Checked Then
Me.TopMost = True
'If Checkbox is not checked then topmost is inactive
ElseIf CheckBox1.Checked = False Then
Me.TopMost = False
End If
End Sub
'When clicked take me to supportforums.net in my default web browser
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
System.Diagnostics.Process.Start("http://www.supportforums.net")
End Sub
Private Sub FButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FButton1.Click
'This will clear the textbox everytime you hit the button so that the new string value can replace the original converted text without having the press the clear button
TextBox2.Text = ""
If TextBox1.Text.Trim.Length = 0 Then
MsgBox("Cannot translate only spaces in the input text field", MsgBoxStyle.Critical, "Error - PigLatin Translator v1.0")
Exit Sub
ElseIf TextBox1.Text = "a" Then
TextBox2.Text = "a-way"
ElseIf TextBox1.Text.Length = 1 Then
MsgBox("There was an error while trying to translate the input text. Please try again or make sure you spelled it correctly", MsgBoxStyle.Critical, "Error - PigLatin Translator v1.0")
Exit Sub
ElseIf TextBox1.Text.StartsWith(" ") Then
MsgBox("There was an error while trying to translate the input text. You may have a space in front of your input text. Please remove the space and try again", MsgBoxStyle.Critical, "Error - PigLatin Translator v1.0")
Exit Sub
End If
'Convert To PigLatin >
If RadioButton1.Checked = True Then
'Checks to make sure textbox field is not empty
If TextBox1.Text = "" Then
MsgBox("Please type in your text to translate before proceeding", MsgBoxStyle.Information, "Information - PigLatin Translator v1.0")
Exit Sub
ElseIf TextBox1.Text.Contains("-") Then
MsgBox("The input text is already in PigLatin. Please change it to translate to English, or try typing in something else", MsgBoxStyle.Critical, "Error - PigLatin Translator v1.0")
Else
'splits the entire text into indivisdual words for the loop to use the function (Convert_PigLatin) to all words before putting it into the output text field
'Separates or splits each word in the loop with a space
Dim strWords() As String = TextBox1.Text.Split(" ")
For i = 0 To strWords.Length - 1
'this loops through each word converting it to pig-latin
strWords(i) = Convert_PigLatin(strWords(i))
Next
'after each word is converted, it joins the string together and seperates
'each word by a space
TextBox2.Text = Join(strWords, " ")
End If
End If
'Convert to English >
If RadioButton2.Checked = True Then
'Without "-" Give output textbox value the same as the input text field string, and show messagebox with error
If Not TextBox1.Text.Contains("-") Then
TextBox2.Text = TextBox1.Text
MsgBox("Could not translate to English. Please check to make sure that you have entered your text in proper PigLatin or that you haven't entered in English by accident. The translated text may or may not be translated to English.", MsgBoxStyle.Critical, "Error - PigLatin Translator v1.0")
Exit Sub
Else
'Puts each word into a string array
Dim strWords() As String = TextBox1.Text.Split(" ")
For i = 0 To strWords.Length - 1
'Translate each word with the loop
strWords(i) = Convert_English(strWords(i))
Next
'join each translated word back to a sentence separated by a space " "
TextBox2.Text = Join(strWords, " ")
End If
End If
End Sub
Private Function Convert_PigLatin(ByVal strWord As String) As String
Dim VowelList As Char 'Finds the first vowel
Dim noVowels As String 'For if there is no Vowels in the wor
Dim SplitText As String 'Takes the first letters before the first vowel and appends it after a hyphen
Dim TextResult As String 'Translated string value to be displayed in output text field
Dim iIndex As Integer 'Splits the text by the voweld
For i = 0 To strWord.Length - 1
'Loop through each character to find the first vowel in the word
VowelList = strWord.Substring(i, 1)
Select Case VowelList.ToString.ToLower
'Defines our Vowels to search for, "Y" has been added in this case in addition to the normal Vowels
Case "a", "e", "i", "o", "u", "y"
'If vowel is the first character (0 means it's the first in this loop) return input text string value (strWord) and append -way to the end
If i = 0 Then Return strWord & "-way"
'strSplit is what gets added to the end of the word
SplitText = strWord.Substring(0, i).ToLower
'This is just the location of the first vowel in the word
iIndex = strWord.IndexOf(VowelList)
'Makes the output start with the first vowel found in the loop for the word, followed by the "-", then the characters taken from the beginning
'Before the vowel (strSplit), and append 'ay' at the end.
TextResult = strWord.Substring(iIndex, strWord.Length - iIndex) & "-" & SplitText & "ay"
'Return the translated word (strResult) is what goes into The output text field for the converted words.
Return TextResult
Exit For
End Select
Next
'If there are no vowels in the input text field, take the original string value, and find the second letter in the word (1)
noVowels = strWord.Substring(1, 1)
SplitText = strWord.Substring(0, 1).ToLower
'Text result as original input subtracting the first letter in the string, Appending "-", "the first split letter, and "ay" on the end.
TextResult = strWord.Substring(1, strWord.Length - 1) & "-" & SplitText & "ay"
Return TextResult
End Function
Private Function Convert_English(ByVal strWord As String) As String
Dim iIndex As Integer = strWord.IndexOf("-") 'Reports the first "-" that it finds in the string value to find where the split is
Dim iLastIndex As Integer = strWord.IndexOf("ay") 'Finds original moved text that got added in between "-" and "ay" in the result
Dim TextResult As String 'The result that gets displayed as the translated text
If strWord.Substring(iIndex + 1, 1).ToLower = "w" Then
'If the first letter after the index of "-" happens to be a w, then chances are it's "-way" and it will be removed
TextResult = strWord.Remove(iIndex)
Else
'Moves the letters between '-' and 'ay' and adds it to the front of the string result. Removing "-" and "ay"
TextResult = strWord.Substring(iIndex + 1, iLastIndex - iIndex - 1) & strWord.Substring(0, iIndex)
End If
'Show Translated string (Returns that value)
Return TextResult
End Function
Private Sub FButton3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FButton3.Click
'One of the easiest codes in VB. close/end the application ;)
End
End Sub
Private Sub FButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FButton2.Click
'Clears all of the text in The output Textbox, (Not needed though)
TextBox2.Text = ""
End Sub
Private Sub FButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FButton4.Click
'If TextBox2 is not empty Then execute the code
If Not TextBox2.Text = "" Then
Clipboard.SetText(TextBox2.Text)
Dim CopyText As String = Clipboard.GetText 'This assigns text to clipboard
'Message for confirmation
MsgBox("Your text has been successfully copied to the clipboard!", MsgBoxStyle.Information, "Information - PigLatin Translator v1.0")
'Otherwise, if the textbox area is empty, show this message...
Else : MsgBox("Sorry, there is no text to copy to the clipboard. Please try translating an input text to either English or Piglatin and try again.", MsgBoxStyle.Information, "Information - PigLatin Translator v1.0")
End If
End Sub
End Class
I noticed that it wasn't about anything other than getting people participating in the coding. But I noticed that both of you kept the same default icon for your project and other basic things like that. Always good practice to get into setting up your project though.