VB mini programming language

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BorlandDelphi
    Banned
    New Member
    • Mar 2008
    • 18

    VB mini programming language

    Hi!!! Like you can see in my name I prefer a Borland programs, but today I have start the
    Microsoft programs. Like a basic of the Microsft programs is Visual Basic 6,5,4 or older.
    I need help. I'm making a mini programing language in VB so I need to know how can I detect a
    word that is writen.
    Example =>Start

    Var a:integer;

    Example =>End.

    I need to detect the word 'Var' and to bold it and tht will be like 'Dim' in VB or
    something like tahat.
    I need to detect a letter after 'Var' so tahat will be the name of the (i don't know
    how to tell that on English).
    I need to detect ':' so taht will be the end of the (i don't know
    how to tell that on English).
    I need to detect the 'integer' that will be a type of the (i don't know
    how to tell that on English).
    I need to detect ';' , that will be the end of the statement.

    So any help here isn't bad idea,I think ?


    BorlandDelphi $$$ The best programs I ever see it $$$
  • Robbie
    New Member
    • Mar 2007
    • 180

    #2
    I think the word you want is 'variable' - something to store a value, right? ;)

    You're wanting to make some kind of text (source code) editor in VB6 for another programming language?

    Well, the first immediate problem I see is that I don't know about a 'rich text' control in VB6. You'd need something more than just a VB
    TextBox control because you can't make specific parts of a TextBox's text be bold or of a different colour to the rest of the text in the same control.

    To actually detect the things you want to detect - such as 'var' or ':' - you can use InStr(). That function looks for a small string within a larger string, and it tells you the position in the large string at which the smaller string appears, or gives back 0 if it found nothing. You use it like this (VB 6 code) :
    [code=vb]
    InStr(PositionT oStartLookingFr omWithinTheLarg eString, LargeString, SmallString)

    TextPos = InStr(1, "hello everyone", "e") 'TextPos becomes 2
    TextPos = InStr(4, "hello everyone", "e") 'TextPos becomes 7
    [/code]

    You could then use the information which InStr() returns to know the start and end positions of the text which should be bold (i.e. 'var'). However, how you actually make this text be bold, I don't know (you need some 'rich text' control, and I don't even know if that exists, let alone where you'd find a free one).

    I hope this at least helps a little...
    If you do find out about some Rich Text Edit control, please let me know, because I'd love to have one too!

    Comment

    • BorlandDelphi
      Banned
      New Member
      • Mar 2008
      • 18

      #3
      I just ask for help. My new mini programming language is my problem. I just asko for help. If you want to help do it, if you don't then don't

      BorlanDelphi %The best programs I ever see it"

      Comment

      • Robbie
        New Member
        • Mar 2007
        • 180

        #4
        Originally posted by BorlandDelphi
        I just ask for help. My new mini programming language is my problem. I just asko for help. If you want to help do it, if you don't then don't"
        Huh? I really was trying to help.

        I recommend you check the InStr(), which I mentioned in my previous post, and maybe also InStrRev() (which scans backwards through the string). Using Mid(), you can also extract a piece of text within a string.
        [code=vb]
        'Mid works like this: Mid(AllText, StartCharacter, NumberOfCharact ers)
        Text = Mid("Something" , 4,2) 'Text becomes "et"
        [/code]

        So, you could use InStr() to get the position of "var" within a line of the text, add 4 to that value (then you'll be at the position of the start of the variable's name). Then you can use Mid() to extract the name of the variable. If you want something like "as string" to be detected, you can use InStr() to find the position of " as ", then use Mid() to extract what's in between "var " and " as ".
        Example:

        [code=vb]
        WholeText = " var MyVariableName as string"
        StartPos = InStr(1, WholeText, "var ") + 4
        EndPos = InStrRev(WholeT ext, " as ")
        VarName = Mid(WholeText, StartPos, EndPos - StartPos)
        [/code]
        Now VarName is "MyVariableName ". Using that kind of technique, you can use InStr() to look for keywords such as "var" within typed text (code) to use as waypoints for finding specific text which the user typed.

        Comment

        • BorlandDelphi
          Banned
          New Member
          • Mar 2008
          • 18

          #5
          Oh,sorry. I don't have enought time to read. Well thanks for the
          word 'varible' ( I need to remember it) and about the function
          InStr(). Thanks a lot for helping me. You can bold, color, underline
          and other thinks whit the text in RichTextBox or TextBox. By the way
          if you need a help about Rich and Text Box let me know,I will help you.

          PS: I need a book for computer. I need a book to explain me
          how work all the electronic things,CPU,RAM, registry. I like to know
          how go the bits in the CPU , how work RAM or whit sample words
          I LIKE TO KNOW HOW WORK HARDWARE. I like to know where go the
          electric power and how work the electric chips and ways in the
          MOTHER BOARD. I like to programming whit the CPU and RAM. The
          lowest and more powerfull programming languages.

          By the way, tommorw I will publish the *.exe Instalation File
          and of cource the new version of Easy Extractor v 1.03 whit
          color and more features. Take the full version and use it.
          It's great tool. Next tool will be a Easy Open\Save tool for VB6 or 5.
          You addit like control and you can use it to open or save a *.txt.
          Soon you will enjoy whit the Easy Extractor tool. Do someone
          like to publish his own program????

          BorlandDelphi *****Delphi - the best program *****

          Comment

          • Robbie
            New Member
            • Mar 2007
            • 180

            #6
            Originally posted by BorlandDelphi
            Oh,sorry. I don't have enought time to read. Well thanks for the
            word 'varible' ( I need to remember it) and about the function
            InStr(). Thanks a lot for helping me. You can bold, color, underline
            and other thinks whit the text in RichTextBox or TextBox. By the way
            if you need a help about Rich and Text Box let me know,I will help you.

            PS: I need a book for computer. I need a book to explain me
            how work all the electronic things,CPU,RAM, registry. I like to know
            how go the bits in the CPU , how work RAM or whit sample words
            I LIKE TO KNOW HOW WORK HARDWARE. I like to know where go the
            electric power and how work the electric chips and ways in the
            MOTHER BOARD. I like to programming whit the CPU and RAM. The
            lowest and more powerfull programming languages.

            By the way, tommorw I will publish the *.exe Instalation File
            and of cource the new version of Easy Extractor v 1.03 whit
            color and more features. Take the full version and use it.
            It's great tool. Next tool will be a Easy Open\Save tool for VB6 or 5.
            You addit like control and you can use it to open or save a *.txt.
            Soon you will enjoy whit the Easy Extractor tool. Do someone
            like to publish his own program????

            BorlandDelphi *****Delphi - the best program *****
            A lot of that kind of low-level stuff will be HARDER (more effort required) to do in Visual Basic, because VB is meant for making more general programs (not so 'accurate', if you know what I mean - I can't word it properly) much more quickly.

            Yes, please tell me about a RichTextBox! There isn't one in the VB6 toolbox by default, so if there is something in 'Project -> Components' which I should be ticking, please let me know what that is! I don't mind playing around with it by myself (in fact, that's how I've taught myself a lot about VB), so you don't need to go into any more detail than simply how to add the RichTextBox control to a form (in VB6). Well... if I have any problems afterwards, I can post a question afterwards. ;)

            I'm glad I could help you, too.

            Comment

            Working...