dcsimg
Results 1 to 6 of 6

Thread: VB6 MusicMDB-Wireframe (based on the MSHFlexGrid)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    3,896

    VB6 MusicMDB-Wireframe (based on the MSHFlexGrid)

    Sinve the topic (a "Music-archive in an *.mdb") just came up in the normal Forum ...

    here a little Demo of mine, which I wrote over a decade ago, to show how to use ADO/JET in conjunction with the MSHFlexGrid.

    (The HFlex is being wrapped in two Private UserControls, to utilize and enhance it with sorting-capabilities,
    as well as showing its usage as a kind of Property-Grid (to be able to edit single-records, selected in the Main-Grid).

    A third UserControl is included as well - which shows, how to use its internal Async http-Request-capabilities,
    to find and download "Cover-Art" for Music-Albums online...



    Here is the Demo-Zip: MusicMDBDemo.zip

    have fun,

    Olaf

  2. #2
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,124

    Re: VB6 MusicMDB-Wireframe (based on the MSHFlexGrid)

    There is a small bug:

    Click on the Title column-header and then click on Album column-header:

    Code:
    Private Sub MainGrid_ApplySorting(SortColumn As String, ByVal Desc As Boolean)
    Dim SQL$
      SQL = IIf(Len(MainGrid.LastSQLString), MainGrid.LastSQLString, GridBaseSelect)
      SQL = Split(SQL, " Order By", , vbTextCompare)(0)
      MainGrid.Fill DBMain.GetRs(SQL & " Order By " & SortColumn & IIf(Desc, " Desc", ""))
    End Sub
    SQL:

    Select ID, Artist, Title, Album From Songs Where Artist Like '%42%' Order By Title Desc Order By Album

  3. #3
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    292

    Re: VB6 MusicMDB-Wireframe (based on the MSHFlexGrid)

    Quote Originally Posted by dreammanor View Post
    There is a small bug:

    Click on the Title column-header and then click on Album column-header:

    Code:
    Private Sub MainGrid_ApplySorting(SortColumn As String, ByVal Desc As Boolean)
    Dim SQL$
      SQL = IIf(Len(MainGrid.LastSQLString), MainGrid.LastSQLString, GridBaseSelect)
      SQL = Split(SQL, " Order By", , vbTextCompare)(0)
      MainGrid.Fill DBMain.GetRs(SQL & " Order By " & SortColumn & IIf(Desc, " Desc", ""))
    End Sub
    SQL:

    Select ID, Artist, Title, Album From Songs Where Artist Like '%42%' Order By Title Desc Order By Album
    你肯定使用了XP兼容模式.

    You definitely use the XP compatibility mode.have this bug

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    3,896

    Re: VB6 MusicMDB-Wireframe (based on the MSHFlexGrid)

    Quote Originally Posted by dreammanor View Post
    There is a small bug:

    Click on the Title column-header and then click on Album column-header:

    Code:
    Private Sub MainGrid_ApplySorting(SortColumn As String, ByVal Desc As Boolean)
    Dim SQL$
      SQL = IIf(Len(MainGrid.LastSQLString), MainGrid.LastSQLString, GridBaseSelect)
      SQL = Split(SQL, " Order By", , vbTextCompare)(0)
      MainGrid.Fill DBMain.GetRs(SQL & " Order By " & SortColumn & IIf(Desc, " Desc", ""))
    End Sub
    SQL:
    Select ID, Artist, Title, Album From Songs Where Artist Like '%42%' Order By Title Desc Order By Album
    In that case (as the resulting "faulty SQL-string clearly shows") - the "bug" is in the VB6-runtime then...
    (since the runtime apparently does not do, what it was instructed to do -> in the Split-Instruction)...

    This might be related to the stuff you've brought up earlier in another thread,
    where InStr() was failing to honor Case-Insensitive searches via vbTextCompare (on chinese systems, where the IDE works in DBCS-mode).

    A workaround that might do (using LCase$ instead) - would be the following:
    Code:
    Private Sub MainGrid_ApplySorting(SortColumn As String, ByVal Desc As Boolean)
    Dim SQL$
      SQL = IIf(Len(MainGrid.LastSQLString), MainGrid.LastSQLString, GridBaseSelect)
      Dim Pos&: Pos = InStr(LCase$(SQL), " order by") - 1: If Pos <= 0 Then Pos = Len(SQL)
    '  SQL = Split(SQL, " Order By", , vbTextCompare)(0)  ' <- does not work correctly on some chinese systems
      MainGrid.Fill DBMain.GetRs(Left$(SQL, Pos) & " Order By " & SortColumn & IIf(Desc, " Desc", ""))
    End Sub
    HTH

    Olaf

  5. #5
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,124

    Re: VB6 MusicMDB-Wireframe (based on the MSHFlexGrid)

    Quote Originally Posted by xxdoc123 View Post
    你肯定使用了XP兼容模式.

    You definitely use the XP compatibility mode.have this bug
    It's a problem caused by Instr.

  6. #6
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,124

    Re: VB6 MusicMDB-Wireframe (based on the MSHFlexGrid)

    Quote Originally Posted by Schmidt View Post
    In that case (as the resulting "faulty SQL-string clearly shows") - the "bug" is in the VB6-runtime then...
    (since the runtime apparently does not do, what it was instructed to do -> in the Split-Instruction)...

    This might be related to the stuff you've brought up earlier in another thread,
    where InStr() was failing to honor Case-Insensitive searches via vbTextCompare (on chinese systems, where the IDE works in DBCS-mode).

    A workaround that might do (using LCase$ instead) - would be the following:
    Code:
    Private Sub MainGrid_ApplySorting(SortColumn As String, ByVal Desc As Boolean)
    Dim SQL$
      SQL = IIf(Len(MainGrid.LastSQLString), MainGrid.LastSQLString, GridBaseSelect)
      Dim Pos&: Pos = InStr(LCase$(SQL), " order by") - 1: If Pos <= 0 Then Pos = Len(SQL)
    '  SQL = Split(SQL, " Order By", , vbTextCompare)(0)  ' <- does not work correctly on some chinese systems
      MainGrid.Fill DBMain.GetRs(Left$(SQL, Pos) & " Order By " & SortColumn & IIf(Desc, " Desc", ""))
    End Sub
    HTH

    Olaf
    Yes, you're right. It's a problem caused by Instr on my Chinese Win10

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width