468,301 Members | 1,449 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,301 developers. It's quick & easy.

Help!

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
1 746
Killer42
8,434 Expert 8TB
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.

Similar topics

9 posts views Thread by Tom | last post: by
6 posts views Thread by wukexin | last post: by
3 posts views Thread by Colin J. Williams | last post: by
7 posts views Thread by Corepaul | last post: by
5 posts views Thread by Steve | last post: by
8 posts views Thread by Mark | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.