I'm not the most sophisticated programmer, so you'll have to forgive me as I may be approaching this totally incorrectly.
One of the programs I'm working on now deals with Morse Code and different methods to output data to the user in Morse Code...example, PC beeps or with wav files.
The concept is this:
User selects output method, user selects demonstration and clicks play.
The demonstration directly corresponds to a specific file. Read in the file when the user clicks play and then sound the file one character at a time (including spaces) via the output method chosen by the user.
I've got almost everything working but I'm having difficulties with the manner in which I'm reading the file and then calling the output method.
The core of my "reader" module is the following:
sub beepCharacters()Dim sr As IO.StreamReader = New IO.StreamReader(sFile)
Dim MyFile As String
Do
MyFolder = sr.ReadLine()
If MyFolder Is Nothing Then
Exit Do
End If
sndchr&(x.ToString())
Next Loop Until MyFile Is Nothing
sr.Close()
end sub
The assumption here is that the user chooses the value for output method/choice. The above code assumes the user selected PC Speaker and then calls the sub beepCharacters() in a module. I'm going on the premise or plan that as i read each character, I'm going to output it using another sub. For instance A is a short beep, short space and a long beep. I've created a sub in my module called sndchrA() which does just that and works fine.
But, here lies my problem.
For Each x In strCharacters
sndchr&(x.ToString())
Next
So, as I'm reading the file and I come across the letter A, I want to call sndchrA(). I assumed that I could append the file name with the proper chracter to call the proper sub. However, before even trying to debug, I can see I'm going to throw an exception because as the code is written, there's no declaration for sndchr.
Do I need to declar sndchr as a public string first Or, am I approaching what I'm doing from a bad design
Thanks
Ted

Calling a sub while reading an array?
Nick Cole
sub beepCharacters()
Dim sr As IO.StreamReader = New IO.StreamReader(sFile)
Dim MyFile As String
Do
MyFolder = sr.ReadLine()
If MyFolder Is Nothing Then
For Each x In strCharactersExit Do
End If
sndchr(x.ToString())
Next
Loop Until MyFile Is Nothing
sr.Close()
end sub
sub sndchr(byval strCharacter as string )
select case strCharacter.tolower
case "a"
Console.Beep(400, amdotLen) 'dot
Thread.Sleep(amdotLen)
Console.Beep(400, amdashLen) 'dash
Thread.Sleep(amchrspaceLen) 'Let's put in character space at end of elements
case "b"
.....
end select
End Sub
kashif afzaal
Yu Chai
FBCJunior
Bernard Normier
AH! Excellent, this gives me a great idea to embed my case and if statements.
Many thanks!
Ted
liuweili
This makes much more sense to me. Thank you for the suggestion!
Ted
mp2005
I guess that's part of my question. I'm trying to dynamically create the method to call based on what character is being read from the file.
So, sndchr + character A read from the file = sndchrA()
Ted
Nick DeJacimo
Select Case x.ToLower()
Case "a"
sndchrA(x.ToString())
break
Case "b"
sndchrB(x.ToString())
break
Case "c"
sndchrC(x.ToString())
break
End Select
'----------------------------------------------------------------
' Converted from C# to VB .NET using CSharpToVBConverter(1.2).
' Developed by: Kamal Patel (http://www.KamalPatel.net)
'----------------------------------------------------------------
Adhamz
It's within the same module.
Here's the sub:
Sub
sndchrA()Console.Beep(400, amdotLen) 'dot
Thread.Sleep(amdotLen)
Console.Beep(400, amdashLen) 'dash
Thread.Sleep(amchrspaceLen) 'Let's put in character space at end of elements
End Sub
My variabel amdotLen, amdashLen and amchrspaceLen are public variables defined within the same module.
Ted