[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Strings

Posted on 2004-08-10
9
Medium Priority
?
239 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

649 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