Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all 21128 articles
Browse latest View live

How to pass data to Template created in MS-Word

$
0
0
hi

How to pass data to Template created in MS-Word from Visual Basic

Thanks

Feeding a listview from two tables

$
0
0
Hi experts
I have a problem to populate a listview from two tables
this is my code:
Code:

select * from table1 inner join table2 on table1.Id = table2.PID
the code is working if I add records to both tables.
But if I add a record to table1 without adding the same record to the second table, this record doesn't appear on the listview.
What I did to solve the issue is to carry out two querries:
Code:

select * from table1
then
Code:

select * from table2
the codes are working. I mean I can see the new record on the listview without being recorded on table 2 but I get an error 'index out of bounds'
thanks for helping me

Update Syntax in Access not the same as in vb 6 code why?

$
0
0
hey
i have a code that update a certain field if it contains this mark [']
when i run it in the access table it works fine
when i run it in the vb 6 code i get a error why?
this is the code
in access
Code:

UPDATE Customers SET FullName = Replace(FullName,"'","")
in vb 6
Code:

CN.Execute "UPDATE Customers SET FullName = Replace(FullName," ' ","")"
tnx for any help
salsa :)

[RESOLVED] Feeding a listview from two tables

$
0
0
Hi experts
I have a problem to populate a listview from two tables
this is my code:
Code:

select * from table1 inner join table2 on table1.Id = table2.PID
the code is working if I add records to both tables.
But if I add a record to table1 without adding the same record to the second table, this record doesn't appear on the listview.
What I did to solve the issue is to carry out two querries:
Code:

select * from table1
then
Code:

select * from table2
the codes are working. I mean I can see the new record on the listview without being recorded on table 2 but I get an error 'index out of bounds'
thanks for helping me

[RESOLVED] Async in VB6 ?

$
0
0
Hello,
I'm looking for a sample to place a procedure in another thread. So, to do like in c# Async/await...
I found a sample in a very good website but this website is "falling" : No download doesn't work : http://www.vbaccelerator.com/home/VB...e/article.html

My question : Someone is have this file : Runnable Type Library : Runnable.TLB

Thanks you and have a good day
Christophe

[RESOLVED] RC5 cWidgetForm MinButton and MaxButton don't have any effect?

$
0
0
The following lines didn't give the form a Min or Max Button:

Code:

  fMain.Form.MinButton = True
  fMain.Form.MaxButton = True
  fMain.Form.Show

P.S. Anyone knows how to set the form start location as "Center Screen", this doesn't work:

Code:

fMain.Form.StartUpPosition = vbStartUpScreen
fMain.Form.Show

Need Help On LISTVIEW...

$
0
0
Hi, all.

i want only balance stock in my ListView, Item wise.

i am using following code for that, but it can't work.

Code:

Private Sub cmdVALL_Click()
    Dim PQt, SQty, PQATot, AvAmt As Double
    Dim strFREE As String
    PQt = 0
    SQty = 0
    PQATot = 0
    AvAmt = 0
   
    ListView1.ListItems.Clear
   
    Set rs = db.OpenRecordset("Select * From StockInOut ORder By ItemId")
   
    PB1.Value = 0          'PB1 = ProgressBar1
    PB1.Max = rs.RecordCount
    strFREE = rs!ItemId
   
    Do While Not rs.EOF
    If Val(strFREE) = rs!ItemId Then
        Dim lst As ListItem
        Set lst = ListView1.ListItems.Add()
            lst.Text = rs!ItemId
            lst.SubItems(1) = rs!ItemNM
            lst.SubItems(2) = rs!UnitNM
                PQt = PQt + (rs!PQty + rs!PFreeQty)
                SQty = SQty + (rs!BSQty + rs!BSFreeQty)
            lst.SubItems(3) = PQt - SQty
            lst.SubItems(4) = ""
            lst.Tag = rs!ItemId
           
'            PB1.Value = PB1.Value + 1
            rs.MoveNext
        Else
            strFREE = rs!ItemId
                PQt = 0
                SQty = 0
                PQATot = 0
                AvAmt = 0
               
            Set lst = ListView1.ListItems.Add()
                lst.Text = ""
                lst.SubItems(1) = ""
                lst.SubItems(2) = ""
                lst.SubItems(3) = ""
                lst.SubItems(4) = ""
                lst.EnsureVisible
        End If
    Loop
        rs.Close
        Set rs = Nothing
   
   
End Sub

it gives me result like this...

Name:  Error ListView.jpg
Views: 38
Size:  34.4 KB

I Want Result Like This...

Item Name Unit Balance Qty.
Cheesy Garlic...... Box 10
Cream N Onion.... Box -2


so, where i am going wrong in my code.

plz. help.

Thanks.

-Kaushal
Attached Images
 

DatGrid shows nothing!

$
0
0
I have a DataGrid in my project and I populate it using a SQLite recordset like this:
Code:

  sql = "select count(*) from LIST_DTL"
 
  Set QDGRs = Cnn.OpenRecordset(sql)
  RecCnt = QDGRs.RecordCount
 
  txtQueryRecCnt.Text = "" & RecCnt
  Set dgQueryRes.DataSource = QDGRs.DataSource
  dgQueryRes.Refresh

But the grid shows empty.
The textbox that shows the RecCnt shows 1, which is correct, but the grid doesn't show anything at all (just one empty row with two empty columns).
I even change the query to something even more trivial:
Code:

  sql = "select 5, 6"
 
  Set QDGRs = Cnn.OpenRecordset(sql)
  RecCnt = QDGRs.RecordCount
 
  txtQueryRecCnt.Text = "" & RecCnt
  Set dgQueryRes.DataSource = QDGRs.DataSource
  dgQueryRes.Refresh

Still the grid shows empty (again just one empty row with two empty columns)
Whatever I do, doesn't work.
The recordset has records and columns in it, but the grid shows nothing.
Can you please help?
Thanks.

vb6, win7 & fs_command event in shockwave flash object (flash8.ocx)

$
0
0
hi all,

i've an little app in vb6, running ok in winxp: i've a shockwave flash object (flash8.ocx) and this event:

Private Sub ShockwaveFlash1_FSCommand(ByVal command As String, ByVal args As String)
MsgBox command, vbInformation, args
End Sub

this run ok in winxp, but in win7 the event is not fired!!!

any sugestion?

thanks in advance, best regards
victor.

Small glitch with VB6 on Windows 7 64 bits

$
0
0
I have just installed Visual Studio 6.0 Enterprise Edition on a Windows 7 64 bits computer (main gig went up in smoke, literally). Everything works A-OK. All the projects I have tested so far load, run, compile just fine. No registration errors of any kind for dll's, Ocx's have been encountered so far. And all that whether I run VB in administrative mode or not, in XP/SP3 compatibility mode or not. Ole drag/drop work in all settings as well. I am not using paths subject to virtualization.

But it's still early in the game, install is only a couple of days old. Now I prefer (I think) to run in non-administrative mode and non XP compatible.

There's a small glitch I just ran into though. When I "Save Project as..." or "Save Form as...", the opening file dialog box does not show the proper root of the filename but instead nothing or one single random character. This does not happen when I switch to XP/SP3 compatibility mode.

The questions are :

Why?
Is there a cure (other than compatibility mode)?

And the larger question : Is it standard or mandatory practice to run VB6 in Admin, XP compatibility or both on Win7/64?

[HELP] Load dll from resource to memory and call function inside it

$
0
0
Hello all,

Just like the title says, how do i load directly from resource to memory, and then call function inside it?
I've seen something like running exe on memory but nothing with the dll. After crawling around here and there, i couldn't find the one i'm looking.
Using some protection/bundling software seems not working and i personally don't want to use that tools/application.

The goal is to create portable single exe that doesn't have distributable runtime dll, accompanied dll (or whatever you call it), as distributing dll may cause problem, either with file missing, corrupt, infected by unknown virus, and/or other personal reason.
The alternative to this situation is just deploying dll to some path (when it's not available on target machine) and use it as usual. But that means that my dll could be compromised by external harm, even when i delete it after use.

So how can i do that? anyone? :confused::confused:
Thanks in advance

[HELP] Set form or application as system modal (irrelevant with metro)

$
0
0
Hi all,

As far as i know, there are three methods of what you called it "Set form on top"

First is the simplest of all:
Code:

SetWindowPos Me.hWnd, -1, 0, 0, 0, 0, 2 Or 1
The result is just bring window on top + topmost. You can still interract with other application. Can be covered by another topmost window.

Second is using timer periodically to bring window to front.
Code:

Public Function ForceForegroundWindow(ByVal hWnd As Long) As Boolean
    Dim bAttached As Boolean, hWndFore As Long, App_ThreadID As Long, Fore_ThreadID As Long
    hWndFore = GetForegroundWindow
    If hWnd <> hWndFore Then
        App_ThreadID = App.ThreadID
        Fore_ThreadID = GetWindowThreadProcessId(hWndFore)
        If App_ThreadID <> Fore_ThreadID Then
            bAttached = AttachThreadInput(App_ThreadID, Fore_ThreadID, True) <> False
        End If
        Select Case True
        Case SetForegroundWindow(hWnd) <> False, _
            BringWindowToTop(hWnd) <> False, _
            SetActiveWindow(hWnd) <> 0&, _
            SetFocusOn(hWnd) <> 0&
            ForceForegroundWindow = True
        Case Else
            SwitchToThisWindow hWnd
            ForceForegroundWindow = (GetForegroundWindow = hWnd)
        End Select
        If IsIconic(hWnd) Then ShowWindow hWnd, 9 Else ShowWindow hWnd, 5
        If bAttached Then
            bAttached = AttachThreadInput(App_ThreadID, Fore_ThreadID, False) <> False
        End If
    Else
        ForceForegroundWindow = True
    End If
End Function

The effects are like these:
  • Bring window on top + topmost, forcefully, and stealing focus from other application.
  • Hovering other application doesn't trigger balloon/tooltip.
  • Can be covered by other topmost window, but since it's called periodically to bring window to front, it'll just steal the focus again and be the to


But still, you can interract with other application like:
  • click
  • right click -> menu can appear and can be clicked
  • moving other application window
  • basically anything to other application, provided that you do your works twice because of focus-stealing.


And then there is the third method is using system modal, but i don't have the code. That's what i want to know.
Is anyone here ever coded that things?
Code:

Public Declare Function MakeModal Lib "dsmodal.dll" (ByVal AppHwnd As Long, ByVal hwndDest As Long, Optional ByVal Beep As Long = 0) As Long

Call MakeModal me.hWnd, 1, 1

I happened to have some dll from 10 (TEN) years ago (named: dsmodal.dll, not written in vb though) that able to do something like that. It's available on net though.
For some who doesn't know, it has an effect like these:
  • Bring window on top + topmost.
  • Hovering other application still trigger balloon/tooltip.
  • Cannot interact to other applications at all (except ctrl+alt+del to log off when something goes wrong e.g app hang when still on a sysmodal mode).
  • If Beep = 1, then when you click/right-click to other application, it will beep just like when you click your application window when msgbox appear -> it will beep and bypass the event "click"


information regarding this dll:

Name:  1.PNG
Views: 35
Size:  4.0 KB

Name:  2.jpg
Views: 34
Size:  17.4 KB

Name:  3.jpg
Views: 36
Size:  19.4 KB

Some readable, API used. It just like using the second method, but i'm not sure about the logic inside.

Name:  4.jpg
Views: 31
Size:  28.0 KB

Some may say that we "cannot" set window as system modal for various logical reason. But sometimes the time comes when you really need something like this.
In my case, i want to use this method to "secure" firmware upgrade process, as it cannot be interrupted just like when you update your bios using GUI inside Windows.

So, anyone? :confused::confused:

Pardon my english.
Thaks in advance and best regard.
Attached Images
    

RC5 vbWidgets (cwFileList cwDropDownList) suggestions

$
0
0
RC5 [vbWidgets] cwFileList cwDropDownList suggestions

About cwFileList :
I wonder why cwFileList has only 2 events: Click and MouseUpClick

I (and I guess others) would need a MouseMoveOnListItem that whould return the Item-index of mouse over.
It can be done manually by adding a FileListVLIST of type vbWidgets.cwVList
and initializing it with Set FileListVLIST = MyFileList.VList and then "grab" the events of FileListVLIST.
But this, to me, brings to useless increased complexity.


About cwDropDownList :
Recently in cwFileList, it has been implemented a keydown function that find the first item that begins with keyboard typed character. (similar to FileListBox)

I think that this function would be very useful even in any other kind of cWidget LIST : cwDropDownList... and maybe any widgets that uses vList.
Because it is faster to type a keyboard key than scroll with mouse wheel or use scrollbar. (Expecially in "long" lists)

That's it. Just suggestions.

"For... To... on images without arrays

$
0
0
On my form I have 100 Images named Image1, Image2 etc. that are not control arrays. Each with Borderstyle=0.
I would like to change the property Borderstyle to 1 for all images with a Button. Something like that:

Private Sub Command1_Click()
Dim X As Integer
For X = 1 To 100
Image X.BorderStyle = 1
Next X
End Sub

Of course it returns me "Invalid qualifier" at the line 4.
I know it would work if the images were arrays:
Image(X).Borderstyle = 1

Is there a way to do the same in my example without using control arrays?
Sorry for my terrible english.

ActiveBar - Search option

$
0
0
I've developed an application which is using ActiveBar for menu manipulating.

I wonder is there any way i can make an option to search that activebar.

Ex: Run program and in searchbox type ("Towns") it will search all menus/submenus and find exact path to that option navigating through menu.

SQLite examples for vbRichClient?

$
0
0
I would love to use this great lib for a project I'm working on, but I can't find any examples of its use. I looked on vbrichclient.com and there are some great Cairo samples, but I couldn't find anything for SQLite, how to open a DB, etc. How am I missing it? I know it's suppose to be based on ADO, so it should be easy-to-use, but having a working starter project and DB to play with is always nice. I found a sample on PSC that uses vbRichClient3, but I couldn't get it to work with the latest vbRichClient.

RC5 SQLite Question - Converting cRecordset into an In-Memory DB, or is it necessary?

$
0
0
With a very large database at hand, two tables, with millions of rows, now I have concerns over the performance. I need to do thousands of SELECT queries, with aggregation functions, joining, grouping, etc. just to retrieve a small set of data, 10 to 20 rows each time, from a smaller range of rows, i.e. WHERE TAG_ID = 9.

So I am thinking if I can first create a smaller In-Memory DB that has a table of 10 thousand rows from a Recordset obtained by a first filtering, and then making complex queries on this one might be much quicker?

Maybe all of this is unnecessary and SQLite has already done proper optimization for this situation? Or this can be done just by changing the SQL? Or .. I need some help:p

Capture powerpoint mouse click events in VB

$
0
0
My VB program opens, runs and with navigation buttons I can move through slides however, I would like the slide mouse click in the presentation to _Click() on the buttons in my VB.

I have the following declared...

Dim objppt As PowerPoint.Application
Dim pptpres As PowerPoint.Presentation
Dim pptSlide As PowerPoint.Slide
Dim WithEvents pptpresKey As PowerPoint.Application

and this event...

Public Sub pptpresKey_OnSlideShowPageChange()

MsgBox "Slide changed"

End Sub

The above code is my attempt and guess work, so it no surprise it doesn't work.

[RESOLVED] Breaking up a number

$
0
0
Hey, I'm looking for a clever way to break up X into Y, (where Y is a dynamic number of arrays), so that all Y's added together equals X. This could of course easily be done by just dividing X by Y, but then Y will contain decimals in many cases, which won't for my project. Rounding each Y will not work, because then Y might not equal X when added together.

Hypothetical example: X=10 and Y=3, now I don't want each Y to be 3.33, instead I would like them come out as 4+3+3.

[RESOLVED] [HELP] Set form or application as system modal

$
0
0
Hi all,

As far as i know, there are three methods of what you called it "Set form on top"

First is the simplest of all:
Code:

SetWindowPos Me.hWnd, -1, 0, 0, 0, 0, 2 Or 1
The result is just bring window on top + topmost. You can still interract with other application. Can be covered by another topmost window.

Second is using timer periodically to bring window to front.
Code:

Public Function ForceForegroundWindow(ByVal hWnd As Long) As Boolean
    Dim bAttached As Boolean, hWndFore As Long, App_ThreadID As Long, Fore_ThreadID As Long
    hWndFore = GetForegroundWindow
    If hWnd <> hWndFore Then
        App_ThreadID = App.ThreadID
        Fore_ThreadID = GetWindowThreadProcessId(hWndFore)
        If App_ThreadID <> Fore_ThreadID Then
            bAttached = AttachThreadInput(App_ThreadID, Fore_ThreadID, True) <> False
        End If
        Select Case True
        Case SetForegroundWindow(hWnd) <> False, _
            BringWindowToTop(hWnd) <> False, _
            SetActiveWindow(hWnd) <> 0&, _
            SetFocusOn(hWnd) <> 0&
            ForceForegroundWindow = True
        Case Else
            SwitchToThisWindow hWnd
            ForceForegroundWindow = (GetForegroundWindow = hWnd)
        End Select
        If IsIconic(hWnd) Then ShowWindow hWnd, 9 Else ShowWindow hWnd, 5
        If bAttached Then
            bAttached = AttachThreadInput(App_ThreadID, Fore_ThreadID, False) <> False
        End If
    Else
        ForceForegroundWindow = True
    End If
End Function

The effects are like these:
  • Bring window on top + topmost, forcefully, and stealing focus from other application.
  • Hovering other application doesn't trigger balloon/tooltip.
  • Can be covered by other topmost window, but since it's called periodically to bring window to front, it'll just steal the focus again and be the to


But still, you can interract with other application like:
  • click
  • right click -> menu can appear and can be clicked
  • moving other application window
  • basically anything to other application, provided that you do your works twice because of focus-stealing.


And then there is the third method is using system modal, but i don't have the code. That's what i want to know.
Is anyone here ever coded that things?
Code:

Public Declare Function MakeModal Lib "dsmodal.dll" (ByVal AppHwnd As Long, ByVal hwndDest As Long, Optional ByVal Beep As Long = 0) As Long

Call MakeModal me.hWnd, 1, 1

I happened to have some dll from 10 (TEN) years ago (named: dsmodal.dll, not written in vb though) that able to do something like that. It's available on net though.
For some who doesn't know, it has an effect like these:
  • Bring window on top + topmost.
  • Hovering other application still trigger balloon/tooltip.
  • Cannot interact to other applications at all (except ctrl+alt+del to log off when something goes wrong e.g app hang when still on a sysmodal mode).
  • If Beep = 1, then when you click/right-click to other application, it will beep just like when you click your application window when msgbox appear -> it will beep and bypass the event "click"


information regarding this dll:

Name:  1.PNG
Views: 79
Size:  4.0 KB

Name:  2.jpg
Views: 78
Size:  17.4 KB

Name:  3.jpg
Views: 80
Size:  19.4 KB

Some readable, API used. It just like using the second method, but i'm not sure about the logic inside.

Name:  4.jpg
Views: 75
Size:  28.0 KB

Some may say that we "cannot" set window as system modal for various logical reason. But sometimes the time comes when you really need something like this.
In my case, i want to use this method to "secure" firmware upgrade process, as it cannot be interrupted just like when you update your bios using GUI inside Windows.

So, anyone? :confused::confused:

Pardon my english.
Thaks in advance and best regard.
Attached Images
    
Viewing all 21128 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>