Results 1 to 16 of 16

Thread: Making my form look good

  1. #1

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Making my form look good

    Hello,

    I've got a little program I whipped up and it looks very boring. I really like the way how vb6 is setup. Is there any graphics or pictures I can put on my form to make it look better?

    Screen Shot:
    Attached Images Attached Images  

  2. #2
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Making my form look good

    I have attached 403 .ico files that you might want to check out.
    Attached Files Attached Files

  3. #3

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Making my form look good

    Thanks I wish I had those in the earlier stages of my project. But does anyone have like boarders or some kinda template I can use for a program that creates text files?

  4. #4

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Making my form look good

    I've got a question with this...

    is there a way to tell what line, and what colon the cursor is on in a rich text box?

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Making my form look good

    Quote Originally Posted by paralinx
    is there a way to tell what line, and what colon the cursor is on in a rich text box?
    Yes, getting the line is very easy since the RichTextBox has a GetLineFromChar method.
    VB Code:
    1. MsgBox "The current line is " & RichTextBox1.GetLineFromChar(RichTextBox1.SelStart) + 1
    I add 1 to this since the line number returned is zero based. To get the current column position requires an API call and a simple calculation.
    VB Code:
    1. Private Declare Function SendMessage _
    2.  Lib "user32.dll" Alias "SendMessageA" ( _
    3.  ByVal hwnd As Long, _
    4.  ByVal wMsg As Long, _
    5.  ByVal wParam As Long, _
    6.  ByRef lParam As Any _
    7. ) As Long
    8.  
    9. Private Const EM_LINEINDEX As Long = &HBB
    10.  
    11. Public Function GetCol(rtfBox As RichTextBox) As Long
    12.     GetCol = rtfBox.SelStart - SendMessage(rtfBox.hwnd, EM_LINEINDEX, _
    13.       rtfBox.GetLineFromChar(rtfBox.SelStart), 0)
    14. End Function
    The above code sends the EM_LINEINDEX message to get the character index of the first character on the active line. Subtracting that from the current caret position gets the column position of the current line.
    VB Code:
    1. MsgBox "Current column position is: " & GetCol(RichTextBox1)

  6. #6

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Making my form look good

    thanks joacim it works perfectly

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Making my form look good

    Add this to your form and see if you like it. I can't remember where I got it, but I've had it for a long time, and have used it many, many times.
    VB Code:
    1. Private Sub Form_Paint()
    2. Dim lngY As Long, colorchange As Integer
    3. ScaleMode = vbPixels
    4. DrawStyle = 5
    5. FillStyle = 0
    6. For lngY = 0 To ScaleHeight
    7.     colorchange = (255 - (lngY * 255) \ ScaleHeight)
    8.     FillColor = RGB(colorchange, colorchange, colorchange)
    9.     Line (-1, lngY - 1)-(ScaleWidth, lngY + 1), , B
    10. Next lngY
    11. End Sub

  8. #8

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Making my form look good

    Ok, well joacim, I found a flaw in your code for the line and colon.

    It won't go to the line and colon when i enter a few times, and then click up on a higher line. It will stay on the bottom one...

  9. #9
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Making my form look good

    Sorry, but I have no idea what you mean? Can't you move the text caret? Aren't your display updated???

  10. #10

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Making my form look good

    Ok it is kindof hard to explain but when I press enter 5 times it will give me line 5, but when i click on line 3 my label will stay on line 5. I think it's because I put the code into rtb_Change. Where should I put the code?

  11. #11
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Making my form look good

    Oh I see, so there is actually not a flaw in my code but the flaw is in where you put the call . Try rtb_SelChange instead.

  12. #12

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Making my form look good

    Yes sorry didn't mean to say your code was bad. It's very very good

  13. #13

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Making my form look good

    Ok now i've got another question for all you vb fanatics out there. How the heck do I use directory list box? I put one on my form but how do I tell it what to look for in the folders and to select the file and do something with it.

  14. #14
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Making my form look good

    Add a FileListBox as well. This control has a Pattern property that you can change so it will show only files that matches that pattern (for example "*.txt" will only show text files). Now you need to sync the FileListBox with the DirListBox, which you do like this:
    VB Code:
    1. Private Sub Dir1_Change()
    2.     File1.Path = Dir1.Path
    3. End Sub

  15. #15

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Making my form look good

    Ok now I've attempted to open up a text file with the file list box... with no success here is the code i tried:
    VB Code:
    1. Private Sub File1_Click()
    2.     dircount = dircount + 1
    3.     If dircount = 2 Then
    4.         Open Dir1.Path For Input As #1
    5.             txtWriteTab.Text = LOF(1)
    6.         Close #1
    7.         dircount = 0
    8.     End If
    9. End Sub

  16. #16
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Making my form look good

    What you are trying to do is to open a folder for Input instead of the selected file.
    VB Code:
    1. Dim sFileName As String
    2. sFileName = File1.Path
    3. If Right$(sFileName, 1) <> "\" Then
    4.     sFileName = sFileName & "\"
    5. End If
    6. sFileName = sFileName & File1.FileName
    7. Open sFileName For Input As #1
    8.     txtWriteTab.Text = Input(LOF(1), 1)
    9. Close #1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width