?
Solved

Strings

Posted on 2004-08-10
9
Medium Priority
?
238 Views
Last Modified: 2010-04-23
i have this application which i use a picture box to display letters (A- Z).  I used x and y coordinated to create the letters.  I am having difficulty in trying to display a word or sentence to the picture box through a text box.  Should something like a String.ToCharArray() be used to reference each individual character or a string.chars to search the string??  I am really stuck here as how to solve this.

heres an example of the letter Capital S i have created

Private Sub S(ByVal C As Integer, ByVal R As Integer)
' C - Column
' R - Row
        Dim index As Integer
        Dim I As Integer

        'S-------------------------------------------------------------------
        For index = 0 To 2
            myRoadSign.SetLight(C, 1 + index + R, True)
        Next
        For I = 1 To 3
            myRoadSign.SetLight(C + I, 0 + R, True)

        Next
        myRoadSign.SetLight(C + I, 1 + R, True)

        For I = 0 To 2
            myRoadSign.SetLight(C + 4, I + 5 + R, True)

        Next
        For I = 1 To 3
            myRoadSign.SetLight(C + I, 8 + R, True)

        Next
        myRoadSign.SetLight(C + 0, 7 + R, True)
        For I = 1 To 3
            myRoadSign.SetLight(C + I, 4 + R, True)
        Next

    End Sub

I call the function like this with hard coded values Call S(11, 36 )
below is a small function to test if the letter is uppercase and then calls the S function dynamically.  this obviously doens't work

 Public Sub WLBoard(ByVal text As String)
Dim i As Integer = 0
While i <> -1
If text(i) = "S" Then ' error
upperA(xpos, ypos)
End If
End While
End Sub

I want to display the words or sentences dynamically.  Any help will be very much appreciated.  

gbilios


0
Comment
Question by:gbilios
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 520 total points
ID: 11769897
To access the individual characters in a string iteratively you would do something like this:

Public Sub WLBoard(ByVal text As String)
    Dim i As Integer
    Dim c As String
    For i = 0 To text.Length - 1
        c = text.Substring(i, 1)
        If c.equals("S") Then
            upperA(xpos, ypos)
        End If
    Next i
End Sub
0
 

Author Comment

by:gbilios
ID: 11769926
i appreciate your quick reply.  So if i added if else statements  for the entire alphabet, then me typing in a word would be displayed exactly as i have typed it in the textbox?

upperA(xpos, ypos)  'xpos is Columns and ypos is Rows

I have experimented with various ways but the most simplest would be

Col = Col + 6 ' moves the entire letter to the next column

I added 6 because i dont want the letters to sit ontop of each other.  Is there a function to detect spaces so that i can write sentences in the picture box.

Would there be an additional for loop to allow the x and y coordinates to be done dynamically instead of me hard coding it like this

upperA(0,36)

0
 

Author Comment

by:gbilios
ID: 11770154
i must of missed something . i modified the line of code :

upperA(xpos, ypos) to upperA(i*6, ypos)

This allows me to enter words and sentences.  prior doing this, there was no way telling or no way the characters or words would form without the column(s) incrementing .

i appreciate all your help

thank-you

gbilios
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:gbilios
ID: 11770864
I have one more query with the following code
Dim i As Integer
    Dim c As String
    For i = 0 To text.Length - 1
        c = text.Substring(i, 1)
        If c.equals("S") Then
            upperA(xpos, ypos)
        End If
    Next i
End Sub

i changed it to

   If c.Equals("A") Then
         Call A(col, row)

           col = col + 6
  else If col > 76 Then
            col = 0
                row = row + 11
            End If

The line Call A(col, row)

enables lines to be displayed when the text too long
With this modified code i am unable to enter spaces
if i change the line Call A(i*6) then that solves it but does not allow me to have multiple lines

Can anyone please help
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 11772248
What is the difference between upperA() and A()?

Can you post some more complete code?  I'm sure we can get it working...

Idle_Mind
0
 

Author Comment

by:gbilios
ID: 11773679
Sorry for the missunderstabding
the program does the basic things which is display the characters to the picture box

for example the sentence above and i keep typing till the end of the line , i should automatically goto the next line the code that does this is

if col > 76 then
row = row + 11 'goto next line 11 rows down
col = 0 ' set column to position 0

A is Upper and lower which i am still doing is lowerA

Private Sub A(ByVal C As Integer, ByVal R As Integer) ' okay, should be upperA
        Dim index As Integer
        Dim I As Integer

        'A-------------------------------------------------------------------

        For index = 0 To 7
            myRoadSign.SetLight(C, 1 + index + R, True)
            myRoadSign.SetLight(C + 4, 1 + index + R, True)

        Next
        For I = 1 To 3
            myRoadSign.SetLight(C + I, 0 + R, True)
        Next

        For I = 1 To 3
            myRoadSign.SetLight(C + I, 4 + R, True)
        Next

    End Sub

    Private Sub lowerA(ByVal C As Integer, ByVal R As Integer)
        Dim index As Integer
        Dim I As Integer

        'a-------------------------------------------------------------------
        For index = 0 To 3

            myRoadSign.SetLight(C + 4, 5 + index + R, True)

        Next

        For index = 0 To 2


            myRoadSign.SetLight(C, 5 + index + R, True)

        Next
        For I = 0 To 2
            myRoadSign.SetLight(C + 1 + I, 4 + R, True)

        Next
        For I = 0 To 1
            myRoadSign.SetLight(C + 1 + I, 4 + R, True)
            myRoadSign.SetLight(C + 1 + I, 8 + R, True)
        Next
        myRoadSign.SetLight(C + 3, 7 + R, True)
       

    End Sub
0
 

Author Comment

by:gbilios
ID: 11773758
i accidentally hity the tab button , got sent without me finishing it

the previous message with the both uppercase and lowercase characters are created using x,y coordinates (columns and rows).

Public Sub WLBoard(ByVal text As String)
        Dim i As Integer
        Dim c As String
        Dim row As Integer = 0 ' Set the Row position to zero
        Dim col As Integer = 0 ' Set the Column position to zero

        For i = 0 To text.Length - 1

            c = text.Substring(i, 1)
            If col > 76 Then
                Call A(col, row)
                row = row + 11
                col = 0
            End If

            If c.Equals("A") Then

                Call A(col, row)

                col = col + 6

            End If

            If c.Equals("a") Then

                Call lowerA(col, row)

                col = col + 6

            End If
At this point i am worrying getting the basics done which is displaying text like i wrote this sentence.  
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 11775806
This what you looking for?

    Public Sub WLBoard(ByVal text As String)
        Dim i As Integer
        Dim c As String
        Dim row As Integer = 0 ' Set the Row position to zero
        Dim col As Integer = 0 ' Set the Column position to zero

        For i = 0 To text.Length - 1
            c = text.Substring(i, 1)
            Select Case c
                Case "A"
                    Call A(col, row)
                Case "a"
                    Call lowerA(col, row)
                Case "B"
                    Call B(col, row)
                Case "b"
                    Call lowerB(col, row)

                    ' add more Case statements for
                    ' all of your other letters in here

                Case Else
                    MsgBox(c, MsgBoxStyle.Information, "Undefined Letter")
            End Select
            col = col + 6
            If col > 76 Then
                row = row + 11
                col = 0
            End If
        Next i
    End Sub
0
 

Author Comment

by:gbilios
ID: 11780674
That is precisely what i did.  Creating the letters and getting them to the picture box wasn't the problem.  It was 'spaces' and the carriage returns i was having problems.    
I solved that problem (spaces & CR) and it was alot simple than i thought.  I worked out exactly what needed to be done.  
I added the if statement
if c.Equals(" ") ' if its a space then add a space
   col = col + 6 ' go six columns to the right
end if

or the case statement

case " "
  col = col + 6

i appreciate your help.

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question