Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BBCoder tool available thread102-1313237 (cont.) 1

Status
Not open for further replies.

harebrain

MIS
Feb 27, 2003
1,146
US
Griffyn,

Sorry, that config.ini of mine screwed things up and I can't get to the reply area anymore. (I don't know how you did it.)

The access violation is gone, but I don't seem to be getting much of the formatting. (See below.)
Code:
[navy][i]// for automatic syntax highlighting see faq102-6487
[/i][/navy][navy][i]// [b]for[/b] automatic syntax highlighting see faq102-6487
[/i][/navy]Private Sub Form_Click()
    Static i As Integer

    If i < [purple]4[/purple] Then
        Unload txtMoney(i + [purple]2[/purple])
        i = i + [purple]1[/purple]
    End If
End Sub

Private Sub Form_Load()
    Dim i As Integer
    Const SPACING = [purple]10[/purple]

    With txtMoney([purple]0[/purple])
        .Move [purple]0[/purple], [purple]0[/purple]
        .Text = [navy]"Text Box [b]in[/b] control [b]array[/b] [teal]#0[/teal]."[/navy]
        .Width = TextWidth([navy]"  TextBox [b]in[/b] control [b]array[/b] [teal]#0[/teal].  "[/navy])
    End With
    With txtMoney([purple]1[/purple])
        .Move [purple]0[/purple], txtMoney([purple]0[/purple]).Top + txtMoney([purple]0[/purple]).Height + SPACING
        .Text = [navy]"Text Box [b]in[/b] control [b]array[/b] [teal]#1[/teal]."[/navy]
        .Width = TextWidth([navy]"  TextBox [b]in[/b] control [b]array[/b] [teal]#1[/teal].  "[/navy])
    End With

    For i = [purple]2[/purple] To [purple]5[/purple]
        Load txtMoney(i)
        txtMoney(i).Text = [navy]"Text Box [b]in[/b] control [b]array[/b] [teal]#[/teal]"[/navy] & Str$(i)
        txtMoney(i).Move [purple]0[/purple], txtMoney(i - [purple]1[/purple]).Top + txtMoney(i - [purple]1[/purple]).Height + SPACING
        txtMoney(i).Visible = True
    Next
End Sub

[green][i][teal]'Private Sub txtMoney_Change(Index As Integer)
[/i][/green][green][i]'[/teal][teal]'    If Index = 0 Then
[/i][/green][green][i]'[/teal][teal]'        MsgBox "You typed in text box[0]."
[/i][/green][green][i]'[/teal][teal]'    Else
[/i][/green][green][i]'[/teal][teal]'        MsgBox "You typed in text box[1]."
[/i][/green][green][i]'[/teal][teal]'    End If
[/i][/green][green][i]'[/teal]
[/i][/green][green][i][teal]'     MsgBox "You typed in text box " & Index
[/i][/green][green][i]'[/teal]End Sub
[/i][/green]
It seems to be treating strings as code and vice versa. I probably did misuse your properties parameter: I listed properties common to many controls.

I'll post the results again with TGML off so you can see the real output.
 
Code:
[navy][i]// for automatic syntax highlighting see faq102-6487
[/i][/navy][navy][i]// [b]for[/b] automatic syntax highlighting see faq102-6487
[/i][/navy]Private Sub Form_Click()
    Static i As Integer

    If i < [purple]4[/purple] Then
        Unload txtMoney(i + [purple]2[/purple])
        i = i + [purple]1[/purple]
    End If
End Sub

Private Sub Form_Load()
    Dim i As Integer
    Const SPACING = [purple]10[/purple]

    With txtMoney([purple]0[/purple])
        .Move [purple]0[/purple], [purple]0[/purple]
        .Text = [navy]"Text Box [b]in[/b] control [b]array[/b] [teal]#0[/teal]."[/navy]
        .Width = TextWidth([navy]"  TextBox [b]in[/b] control [b]array[/b] [teal]#0[/teal].  "[/navy])
    End With
    With txtMoney([purple]1[/purple])
        .Move [purple]0[/purple], txtMoney([purple]0[/purple]).Top + txtMoney([purple]0[/purple]).Height + SPACING
        .Text = [navy]"Text Box [b]in[/b] control [b]array[/b] [teal]#1[/teal]."[/navy]
        .Width = TextWidth([navy]"  TextBox [b]in[/b] control [b]array[/b] [teal]#1[/teal].  "[/navy])
    End With

    For i = [purple]2[/purple] To [purple]5[/purple]
        Load txtMoney(i)
        txtMoney(i).Text = [navy]"Text Box [b]in[/b] control [b]array[/b] [teal]#[/teal]"[/navy] & Str$(i)
        txtMoney(i).Move [purple]0[/purple], txtMoney(i - [purple]1[/purple]).Top + txtMoney(i - [purple]1[/purple]).Height + SPACING
        txtMoney(i).Visible = True
    Next
End Sub

[green][i][teal]'Private Sub txtMoney_Change(Index As Integer)
[/i][/green][green][i]'[/teal][teal]'    If Index = 0 Then
[/i][/green][green][i]'[/teal][teal]'        MsgBox "You typed in text box[0]."
[/i][/green][green][i]'[/teal][teal]'    Else
[/i][/green][green][i]'[/teal][teal]'        MsgBox "You typed in text box[1]."
[/i][/green][green][i]'[/teal][teal]'    End If
[/i][/green][green][i]'[/teal]
[/i][/green][green][i][teal]'     MsgBox "You typed in text box " & Index
[/i][/green][green][i]'[/teal]End Sub
[/i][/green]

 
Hm, it looks almost like the docter ordered, from the script you posted; the numbers are purple, and the comment (on top) is navy, but the 'in' inside the quoted strings is bold, probably as Griff said already he's having diffs with the string handling?

Btw, I'm viewing with FireFox.

The reply box of the original thread was way to the right because of your looong list of VB keywords and properties, so you have to right-scroll the browser quite far that way

HTH
TonHu
 
It would be nice to scroll, but I'm on IE, and no horizontal scroll bar. (Why, oh why?) But now, looking at the old thread, the code wraps. Puzzling.

Ok, good news/bad news:
[ul]
[li]Purple numbers, good[/li]
[li]Strings seem inside-out, i.e., keywords inside strings are processed, those that are code aren't processed[/li]
[li]Comment at top is a Delphi comment, not VB[/li]
[li]Extraneous teal tags in the commented code[/li]
[/ul]

I should probably kill all those properties; they're those that are common to the built-in controls, and their emphasis doesn't really add anything. (Actually, it's confusing, because the objects and other common properties aren't emphasized. Not to mention it's not what Griffyn intended.)
 
I sent an e-mail to the tek-tips support asking them to fix the wrapping on that thread - they've probably modified it to allow it to wrap correctly.

You've given me some great examples and feedback. I'll get stuck into all that and post back soon!
 
I've updated the archive. Link is
I've modified the config.ini with a list of VB6 reserved words I got from the web.

Keep in mind, you can't use the BHO to handle syntax highlighting of VB code when you're posting in a Delphi forum! Use the stand-alone program for such testing, or you could temporarily alter the config.ini URL section, but I don't recommend that.

There's no problem having the BHO installed, and posting already code already highlighted by the stand-alone program. The BHO will ignore any code sections containing the leading comment regarding my FAQ topic.

Your example code from above is now:
Code:
[green][i]' for automatic syntax highlighting see faq102-6487 
[/i][/green][b]Private[/b] [b]Sub[/b] Form_Click()
    [b]Static[/b] i [b]As[/b] [b]Integer[/b]
    [b]If[/b] i < 4 [b]Then[/b]
        Unload txtMoney(i + 2)
        i = i + 1
    [b]End[/b] [b]If[/b]
[b]End[/b] [b]Sub[/b]

[b]Private[/b] [b]Sub[/b] Form_Load()
    [b]Dim[/b] i [b]As[/b] [b]Integer[/b]
    [b]Const[/b] SPACING = 10

    [b]With[/b] txtMoney(0)
        .Move 0, 0
        .Text = [navy]"Text Box in control array #0."[/navy]
        .Width = TextWidth([navy]"  TextBox in control array #0.  "[/navy])
    [b]End[/b] [b]With[/b]
    [b]With[/b] txtMoney(1)
        .Move 0, txtMoney(0).Top + txtMoney(0).Height + SPACING
        .Text = [navy]"Text Box in control array #1."[/navy]
        .Width = TextWidth([navy]"  TextBox in control array #1.  "[/navy])
    [b]End[/b] [b]With[/b]

    [b]For[/b] i = 2 [b]To[/b] 5
        Load txtMoney(i)
        txtMoney(i).Text = [navy]"Text Box in control array #"[/navy] & Str$(i)
        txtMoney(i).Move 0, txtMoney(i - 1).Top + txtMoney(i - 1).Height + SPACING
        txtMoney(i).Visible = True
    [b]Next[/b]
[b]End[/b] [b]Sub[/b]

[green][i]'Private Sub txtMoney_Change(Index As Integer)
[/i][/green][green][i]'    If Index = 0 Then
[/i][/green][green][i]'        MsgBox "You typed in text box[0]."
[/i][/green][green][i]'    Else
[/i][/green][green][i]'        MsgBox "You typed in text box[1]."
[/i][/green][green][i]'    End If
[/i][/green][green][i]'     MsgBox "You typed in text box " & Index
[/i][/green][green][i]'End Sub[/i][/green]
 
Officially awesome, Griffyn!

Wait 'til the VBers get a load of this... They'll find out the next time I post, if not sooner.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top