By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,057 Members | 1,407 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,057 IT Pros & Developers. It's quick & easy.

Help!

P: 1
Hi All!

I am trying to write a program where a user puts in their name as follows:

"Hi my name is X"
"X"
"So glad to meet you, I am X"

Where "X" is the users name.

The program would return:
"Hi X, what can I do for you today?"

---
I am using a Split so it can sort through the textbox

Its important that the program must recognize any name inputted into the textbox, then it could be used again elsewhere in the code, probably in varible form. Therefore I have been using a textfile with a list of names and a variable to pass them though.

Heres the code....I appreciate your time and expertise!

******



'////////
'////////
'CREATE 4 DIFFERENT CLASSES TO INDICATE SPLITS
'///////
'///////
Imports System.IO
Public Class SplitTestSpace
Shared words As String = "My name is Russ, Hello I am , My Name "

Public Shared Sub splitSpace()

Dim splitSpace As String() = words.Split(New [Char]() {" "c})

Dim s As String
For Each s In splitSpace
If s.Trim() <> "" Then

Console.WriteLine(s)
End If
Next s
End Sub 'Main

Public Shared Sub splitComma()

Dim splitComma As String() = words.Split(New [Char]() {","c})


Dim c As String
For Each c In splitComma
If c.Trim() <> "," Then

Console.WriteLine(c)
End If
Next c
End Sub 'Main

Public Shared Sub splitPeriod()

Dim splitPeriod As String() = words.Split(New [Char]() {"."c})

Dim p As String
For Each p In splitPeriod
If p.Trim() <> "" Then

Console.WriteLine(p)
End If
Next p
End Sub 'Main


Public Shared Sub splitSemiColon()

Dim splitSemiColon As String() = words.Split(New [Char]() {"."c})

Dim sc As String
For Each sc In splitSemiColon
If sc.Trim() <> ";" Then

Console.WriteLine(sc)
End If
Next sc
End Sub 'Main
Public Shared Sub userNameTextbox()
Dim userNameStreamReader As New StreamReader("C:GeNiE/usernames.txt") 'page 429 in class textbox
Dim userNameTextbox() As String

'If Then Statement
If userNameStreamReader.Peek = splitSpace(1) Then
userNameTextbox = userNameStreamReader.ReadLine()
End If

If userNameStreamReader.Peek = splitComma(1) Then
userNameTextbox = userNameStreamReader.ReadLine()
End If

If userNameStreamReader.Peek = splitPeriod(1) Then
userNameTextbox = userNameStreamReader.ReadLine()
End If

If userNameStreamReader.Peek = splitSemiColon(1) Then
userNameTextbox = userNameStreamReader.ReadLine()
End If

Me.genieLabel.Text = "Hi" & userNameTextbox & "." & "Is today's request business or personal?"


'Try Catch Statement page 429 of class textbook
Try
Catch
MessageBox.Show("Your response is not vaid. Please try again.")
End Try


'Close the file page 427 in class texbook
userNameStreamReader.Close()
Me.Close()
End Sub
End Class
Nov 25 '06 #1
Share this Question
Share on Google+
1 Reply


Expert 5K+
P: 8,434
Hi globalevel.

Although you explained your intentions fairly well, I couldn't make out exactly what it is that you want from us.
Nov 26 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.