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

[RESOLVED] Long compile times when compiled from command line?

$
0
0
I'm working on an unattended/automated build process, and everything is working nicely except for the fact that I'm seeing huge difference when I compile some of my programs from the command line as opposed to the IDE (File menu > Make).

One in particular takes about 5-6 minutes to compile from the command line vs. a few seconds from the IDE.

The command line I am using is:

"C:\Program Files (x86)\Microsoft Visual Studio\VB98\vb6.exe /m "path to my vbp file" /out "path to a log file" /outdir "path for the compiled file"

Some notes/things I've noticed:
  • Projects that are DLLs with classes and modules only compile quickly whether in the IDE or from the command line.
  • Projects that include UserControls and Forms compile very slowly from the command line, but are quick in the IDE.
  • All projects compile very quickly when compiled in the IDE from the File menu.


Anyone ever see anything like this, and perhaps have a solution? Thanks.

[RESOLVED] Emulate "Open containing folder" functionality

$
0
0
I'm trying to open an Explorer window for a given folder with a given file selected, similar to the "Open Containing Folder" functionality. Ideally I would just pass the file specification to this function and the folder path and file to be selected would both be automatically determined from the spec. But it's no issue to parse the folder path and file name out separately and pass them as separate params, if needed.

I can open the folder of the file using ShellExecute but can't select a specific file. Will any of the ShellExecute parameters help with this or do I need to be looking in a different direction?

TIA
Art

Strange Crash On Exit

$
0
0
Hi

I've noted recently we have started to receive the follow crash when exiting our program. This is happening on all computers. The program functions fine until exit. Has anyone come across this or know what may be the root cause. Any help gratefully received.

The only thing i can think is we recently added a reference 'Microsoft Oulook 16.0 Object Library' as all emails in our company are sent via outlook and we had a need to create a HTML formatted automated email. Previously all emails had been created using the MAPI function. All computers are running windows 7 pro SP1, and the latest microsoft office via a 365 business subscription.
Attached Images
 

[RESOLVED] VB6 "Path Not Found" Error After Update

$
0
0
Hi,

Just updated Windows 10 with the new "Creators Update". Directly after the update my visual basic projects fail to open when opening from a network drive "L:\".
I get the following error when trying to open the project:

Path not found: 'L:\Projects\MyProject.vbp'

The L:\ drive is a mapped network location in windows explorer.

When using the 'Open Project' command on the File menu, the L:\ drive is not visible... However you can browse for it fine using windows explorer. Interestingly, you can open the project from the "recent" tab in the "Open Project" form. However, any code which accesses the L:\ drive in the project does not work.

I have tried basic solutions like changing the compatibility settings, running as an administrator etc... But none of these work.

Thanks for your time and I hope you can help.

-Hustey

how to connect a microsoft excel workbook to visual basic, like using a resource...

$
0
0
Hello I am looking to having a Microsoft worksheet from office 2017 to be imported into a resource file, which I have done by a custom add import into my usercontrol. then I wish to make calls of read/write access to the excel workbook using the usercontrol that I have connected to it, even. then I wish to only have the usercontrol that I have connected to the workbook, to have access to it, and then no other human end-user either remote or local to have control of it, even. nor being able to view it, even.

!! Thanks in advance !!

Fake inheritance [HELP]

$
0
0
There's no reall inheritance in VB6, but I read that we can do fake well inheritance, can anyone give me a simple example for this idea ?

Zero fill right shift in VB6

$
0
0
Hi,
in Javascript we can convert a big number to 32 bit integer with Bitwise Operators, like this:
Code:

4066098149795 >>> 0; // result is: 3059087779
How i can do this in VB6?

CommonDialog -VB6/SP6

$
0
0
My commercial app (a training program) has three .exe's. This app was written in VB6/SP6 several years ago for any version of Windows. Has worked fine until recently when I made some coding changes. Now exe B and exe C work fine, but exe A, the primary exe of the app, has CommonDialog problems. In the VB developer mode, the first time a common dialog reference is encountered, as in the following statement:
For MainDisplay.cdlCommonDialog1.ShowOpen
the "CompileError, Method or Data Member not Found" message is generated.

When I attempt to compile this exe, the following statement:
For LogSetup.cdlCommonDialog1,DialogTitle = "Log File"
generates the same error message.

The coding on each of these apps is essentially t he same, as is the presence of the CommonDialog icon on the toolbar. Yet exe A fails, whereas EXe's B and C execute and compile okay. I'm at my wits end as to where to look, and I have a customer awaiting receipt of the app. I need help badly, and offer thanks in advance.

Hal W

Connection Failures

$
0
0
Hi All,

We have an application written in VB6 using MSADO 2.7 connecting to the local default instance of SQL Server 2008 R2. The application uses the following connection string:

Code:

Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=<Database>;Data Source=<Server>;User ID=<User ID>;Password=<Password>;
Where <Server> is the local machine name. We don't force a protocol but my understanding is that when connecting locally the Shared Memory protocol will be used, with TCP/IP as a fallback in the event Shared Memory is disabled. The server in question has Shared Memory enabled but examining the [sys].[dm_exec_connections] view shows the connection is made with TCP. Even when I attempt to force Shared Memory by using lpc: in front of <Server> the connection is still made with TCP.

Clients using the application run a variation of operating systems, most notably Windows 7, 8.1 and 10. Recently we have noticed an issue where the application will fail on a call to the database with a run-time error of 'Connection failure' (among others, the core issue is the same but the error can manifest differently). We traced this back to an issue where Windows was finding a 'more preferred' WiFi network and in it's attempt to connect to it was dropping the TCP stack on the machine, hence the connection failure. I'm sure there's a more detailed/better way of describing this behaviour, but I'm not a network specialist.

ADO provides no reliable way to detect whether a connection is still (actually) available, as the State property of the connection object doesn't change when the connection drops.

We've looked at changing the logic of the application to be able to handle these failures. While our approach works for read operations, it certainly doesn't work for write operations, especially if those operations are in a transaction (which ours are). We've also looked into non-persistent connections (ie open connection, database operation, close connection) but if the TCP stack is dropped during the database operation we are back to square one.

Due to the above described issue, I have a few questions:

1) Can anyone give any insight on why we are unable to use Shared Memory connections using the connection string above and how to fix? When I use lpc:<Server> to connect to the instance via SSMS the connection works without issue and shows as Shared Memory in the [net_transport] column of [sys].[dm_exec_connections].

2) Would moving to Shared Memory from TCP/IP resolve the connection dropping issue? I realize Windows would handle the connection drops the same, but I'm hoping that by using a local-only protocol the drops would be 'invisible' to our application and we could avoid the issue altogether.

3) Has anyone else encountered something similar to this and addressed it successfully? If so, how did you do it?

Any assistance in this matter is greatly appreciated!

Best Regards

How do I get the description for an HRESULT?

$
0
0
I'm fairly familiar with the Win32 API. Processing errors via Err.LastDLLError (not GetLastError!) and getting the error description via the FormatMessage api works great.

But the latest routine I've coded uses a Shell API (SHOpenFolderAndSelectItems) which returns an HRESULT. Determining if the HRESULT represents success or failure is easy. What I can't figure out is how to get the description of the error code. It seems that FormatMessage can handle some HRESULTS. But is this the correct way to do this? Is there a function like FormatMessage that is used for HRESULTS?

Thanks,
Art

[RESOLVED] Invalid use of null

$
0
0
Hello everyone
I'm calculating the sum of two fields then substructing.
Code:

sSQL = "select Sum(Verse) As TotalSum  Sum(Frais) As TotalSum2 from transac WHERE date_Transac= #" & Format(Date, "mm/dd/yyyy") & "#"
  RS.CursorLocation = adUseClient
RS.Open sSQL, DB, adOpenStatic, adLockOptimistic
Debug.Print val(RS!TotalSum) - val(RS!TotalSum2)

I get Invalid use of null if TotalSum2 is null.
How shall avoid this error please?
thank you

[RESOLVED] How do I get the description for an HRESULT?

$
0
0
I'm fairly familiar with the Win32 API. Processing errors via Err.LastDLLError (not GetLastError!) and getting the error description via the FormatMessage api works great.

But the latest routine I've coded uses a Shell API (SHOpenFolderAndSelectItems) which returns an HRESULT. Determining if the HRESULT represents success or failure is easy. What I can't figure out is how to get the description of the error code. It seems that FormatMessage can handle some HRESULTS. But is this the correct way to do this? Is there a function like FormatMessage that is used for HRESULTS?

Thanks,
Art

RPC server is unavailable when going cross domain.

$
0
0
I'm learning Olaf's RPC of vbRichClient5:
http://www.vbforums.com/showthread.p...ement-per-RC5)

Now I'm having a problem:

When the server computer (win10) and the client computer (win10) are in the same domain (the same WiFi), all RPC-Demos are running normally.

But, when the server computer and the client computer are in different domain (different WiFi), the client computer couldn't connect to the server computer. The error message is "Could not establish an Appserver-Connection". I tested all RPC-Demos, including "RPCChatDemo" and "RPCClientDemo-SQLite-RemoteDB", and the results were the same.

Did anyone encounter this problem? Do I need to do some other configuration?

Thank you for your help.

ConnectToConnectionPoint not working for sinking Ribbon CommandBarButton Click Event

$
0
0
Hi all,

From a VB6 Class , I start a new Excel instance and use the following VB6 code to hook the newly created excel application SheetSeelectionChange event:

The code works fine:

Code:

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "Class1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
 
Private Type GUID
    Data1 As Long
    Data2 As Integer
    Data3 As Integer
    Data4(0 To 7) As Byte
 End Type
 
Private Declare Function IIDFromString Lib "ole32" _
  (ByVal lpsz As Long, lpiid As GUID) As Long


Private Declare Function ConnectToConnectionPoint _
Lib "shlwapi" Alias "#168" _
    (ByVal punk As stdole.IUnknown, _
    ByRef riidEvent As GUID, _
    ByVal fConnect As Long, _
    ByVal punkTarget As stdole.IUnknown, _
    ByRef pdwCookie As Long, _
    Optional ByVal ppcpOut As Long) As Long
 
Private cookie As Long
Private iid As GUID
Private Xl_App As Object
 
Private Sub Class_Initialize()
    Dim iid As GUID
    Dim lRet As Long
   
    Set Xl_App = CreateObject("Excel.Application")
    Xl_App.Visible = True
    Xl_App.Workbooks.Add
   
    Const sIID = "{00024413-0000-0000-C000-000000000046}" 'Excel 'AppEvents' Event Interface ID
    lRet = IIDFromString(StrPtr(sIID), iid)
    Debug.Print lRet
    'Hook the SheetSeelectionChange of the newly created excel
    lRet = ConnectToConnectionPoint(Me, iid, 1, Xl_App, cookie)
    Debug.Print Hex(lRet)
End Sub
 
Private Sub Class_Terminate()
    Dim lRet As Long
    lRet = ConnectToConnectionPoint(Nothing, iid, 0, Xl_App, cookie)
    Debug.Print Hex(lRet), cookie
    If lRet <> 0 Then Exit Sub
End Sub

Public Sub SheetSeelectionChange(ByVal Sh As Object, ByVal Target As Object)
    Attribute SheetSeelectionChange.VB_UserMemId = 1558 '<== DispID
    MsgBox "Sink Event working!"
End Sub

PROBLEM:

Now I would like to sink the Click event of the Security tab button in the Excel Ribbon commandbar in a similar fashion instead of sinking the Excel application event as shown in the above code.

My TypeLib browser shows the following Event interface ID for the _CommandBarButtonEvent :
"{000C0351-0000-0000-C000-000000000046}" and DispId= 1

So I tried using the following code but it fails and the call to ConnectToConnectionPoint now returns the COM error code &H800A0062

This is the VB6 Class code that is failing :
Code:

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "Class1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private Type GUID
    Data1 As Long
    Data2 As Integer
    Data3 As Integer
    Data4(0 To 7) As Byte
 End Type

Private Declare Function IIDFromString Lib "ole32" _
(ByVal lpsz As Long, lpiid As GUID) As Long

Private Declare Function ConnectToConnectionPoint _
Lib "shlwapi" Alias "#168" _
(ByVal punk As stdole.IUnknown, _
    ByRef riidEvent As GUID, _
    ByVal fConnect As Long, _
    ByVal punkTarget As stdole.IUnknown, _
    ByRef pdwCookie As Long, _
    Optional ByVal ppcpOut As Long) As Long

Private cookie As Long
Private iid As GUID
Private oButton As Object
Private Xl_App As Object

Private Sub Class_Initialize()
    Dim iid As GUID
    Dim lRet As Long
   
    Set Xl_App = CreateObject("Excel.Application")
    Xl_App.Visible = True
    Xl_App.Workbooks.Add

    Const sIID = "{000C0351-0000-0000-C000-000000000046}" '<=== _CommandBarButtonEvent IID
   
    lRet = IIDFromString(StrPtr(sIID), iid)
    Debug.Print lRet
   
    'Hook the Macros Security commandbar button on the office ribbon
    Set oButton = Xl_App.CommandBars.FindControl(, 3627)
    lRet = ConnectToConnectionPoint(Me, iid, 1, oButton, cookie)
    Debug.Print Hex(lRet) ' <== Returns Error Code : &H800A0062
End Sub

Private Sub Class_Terminate()
    Dim lRet As Long
    lRet = ConnectToConnectionPoint(Nothing, iid, 0, oButton, cookie)
    Debug.Print Hex(lRet), cookie
    If lRet <> 0 Then Exit Sub
End Sub

Public Sub HookClick(ByVal Ctrl As Object, CancelDefault As Boolean)
    Attribute HookClick.VB_UserMemId = 1 '<== DispID
    MsgBox "Sink Event working!"
End Sub

Can anybody shade some light on this ?

Regards.

Add something when something happen

$
0
0
Hello,
i need it for my task in school. the example program is when i click command button then it will add some text in textbox. then the label will show some text when there is three textbox with same text.
is there a way to code in label so when textbox1, textbox2 and textbox3 show same text in label just like in textbox. and the code is not in the button text. i mean is there a trigger label will change if it theres two textbox show same text?

[RESOLVED] Clear repeats from a listbox

$
0
0
Hi
I found this code on a google search but it is not working as I want I will explain
I load a listbox from an access DB the contents are Years in the db there are many duplicates I run the code and it does remove some of the duplicates but it still leaves 2 of each year how can I amend this to remove all duplicates
Code:

Function RemoveDuplicates()
    Dim item As String
    Dim i As Long, j As Long
   
 With frmBrows_Bank
    For i = 0 To .LYear.ListCount - 1
        item = .LYear.List(i)
        For j = i + 1 To .LYear.ListCount - 1
            If item = .LYear.List(j) Then
                .LYear.RemoveItem j
                Exit For
            End If
        Next
    Next
 End With
End Function

[RESOLVED] How redim preserve works? (concatenating 2D arrays)

$
0
0
1. Is it allocate a completely new memory block and copy old array to a new, so the data in dynamic array is always consistent?
2. How about 2-dimentions array?
3. If 1-st is true, why 1-bound of 2D array cannot be redimensioned?

Pausing while loading IE pages

$
0
0
I have a VBA routine which starts IE at a search site (let's call it phase A). During request processing (phase B), a "Loading..." page is displayed. After that (phase C), the results page comes up and displays a list of results, or else says, "Zero results". The code I have so far will wait until phase C is finished and then check the page to see if it says "Zero results" or not. It works fine but I have to use an application.wait statement in order to make sure that phase C has finished. Otherwise, the routine may check too early and return an incorrect answer.

What I'm trying to do is to have my routine wait until the initial search page has changed to the "Loading..." page; then pause while the loading page is present; then check the final page for the presence of "Zero results". I've gotten it to work crudely by using an "Application.Wait" statement which just pauses things until I know that phase C is finished, but that takes longer than needed. What I really want is a way to have the routine check for the word "Loading..." once phase B has started (but not before), and then proceed once phase B and phase C have ended. The relevant code that I have so far is below. Thanks!

Sub aPrime()
On Error Resume Next
Dim ie As Object
Set ie = CreateObject("internetexplorer.application")
ie.navigate "<URL goes here>"
ie.Visible = False 'If it turns out that there aren't any results from the search, don't even bother to show IE.

Do 'I think these loops wait until the initial search page is fully loaded before proceeding to the app.wait command. Is this right??
Loop Until ie.readystate = 3
Do
Loop Until ie.readystate = 4

Application.Wait (Now + TimeValue("00:00:30")) 'Waiting until the "Loading..." page is gone and the final search results page is fully loaded.

msg = ie.document.body.innerhtml
If InStr(msg, "zero results") = 0 Then
ie.Visible = True

Else
MsgBox ("Nothing found; closing IE and terminating.")
ie.Quit
End If

End Sub

How can I obtain the UNC path for a Mapped drive.

$
0
0
I have some clients that need or at least insist on using mapped drives. Since Win8 and newer OS's are so security conscious it is difficult to move files to these mapped drives especially if the file is an executable.
I have no problem placing an exe through a UNC so I'm hoping that if I use the UNC equivalent of the mapped drive, I will not have this problem anymore.
I'm using VB5 and the target computers are anything from XP to Win10-64 and I have to hit them all.

While I'm at it, it would be handy from time to time in the program to know if I'm running on a 64bit system. Is that available???

Thanks

OLE32.dll issues

$
0
0
ole32.dll resides in c:\windows\system32 on my machine.
I still code in VB5, but periodically examine or run a VB6 program not coded by me.

It appears "ole32.dll" gets stepped on during this process and I end up with problems. Example of problem:

Quote:

Application errors:
==================
Error: (07/18/2017 11:50:21 AM) (Source: Application Error) (EventID: 1000) (User: )
Description: Faulting application name: vb5.exe, version: 5.1.43.19, time stamp: 0x33d12bfb
Faulting module name: ole32.dll, version: 6.1.7601.23775, time stamp: 0x58f4db65
Exception code: 0xc0000005
Fault offset: 0x00028bf6
Faulting process id: 0xe10
Faulting application start time: 0x01d2ffdab2d022bd
Faulting application path: C:\Program Files\DevStudio\VB\vb5.exe
Faulting module path: C:\Windows\system32\ole32.dll
Report Id: cdd32b56-6bd0-11e7-aff6-382c4a64dc5e

Error: (07/17/2017 09:55:56 PM) (Source: Application Error) (EventID: 1000) (User: )
Description: Faulting application name: vb5.exe, version: 5.1.43.19, time stamp: 0x33d12bfb
Faulting module name: ole32.dll, version: 6.1.7601.23775, time stamp: 0x58f4db65
Exception code: 0xc0000005
Fault offset: 0x00028bf6
Faulting process id: 0xd2c
Faulting application start time: 0x01d2ff6724290aac
Faulting application path: C:\Program Files\DevStudio\VB\vb5.exe
Faulting module path: C:\Windows\system32\ole32.dll
Any ideas for a workaround or how to easily resolve?
Viewing all 21822 articles
Browse latest View live


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