Visual Basic Classic





Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.

Share tech news, updates, or what's on your mind.

Sign up to Post


On how to Pragmatically Click
"5 Hours" in the timing TAB of the site below.
the default is "Hourly"

this is the site


Javascript  example
that i could use with
Set IE = CreateObject("InternetExplorer.Application")
and VB6


any example I  could  implement from VB6
currently i have a web-browser control

Thank You
Determine the Perfect Price for Your IT Services
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

project to pragmatically click email "confirm" must be in VB6

the program must:

scan inbox
open email if keyword in subject line example  "Bitrex"
find button with keyword in it example  "confirm" and select it
capture the result screen and save in folder  

Im not sure where or how here on Experts i can post this , or even if I can , any help appreciated.
This is a test question for Rob Jurd to help with a reported bug. Please do not respond.

We have a simple application that was done by a predecessor. All it does is allows users to enter 'item numbers' and send to print. The item data is saved on a separate excel sheet in the same folder. All dll files, EXE. file and excel file are in the same folder. I've just copied this folder to a new machine trying to replicate the process. I can run the application but when I click send to print button on the application I get below error;

"Unhandled exception has occurred in your application if you click continue the application will..."

"could not load file or assembly microsoft.reportviewer.common version="

I've tried installing the relevant files for above exceptions. However, think this is to do more with the 'Print' button on the application and coding behind it.
Please see attached.

Can someone advise what I need to do to get this to work please?

Thanks in advance.
I am sorting the status of a job as Loaded / Unloaded based on the text within the cell. What i need is to have a macro button installed which when pressed should read the cell value in  the status column and if it finds "Loaded" in column "S" then move the entire row to a different workbook (lets call it workbook2). Upon the transfer of the row of data it will delete from the current sheet. Workbook2 will have  two sheets for the sorted data - one for loaded and one for unloaded. An important feature of this code is that workbook2 already exists and therefore this macro will just need to open this notebook and save / close once the rows have been transferred.

My intent is to use this macro command button as an archive button to export the data from the current file to the next available row in  workbook2 (a pre-existing workbook).
Wondering why the code below won't set as the selected item (a number 1-5) based on the database field value?

Thanks in advance for any help!

    sThisRdr = lstRdrPriority.Text
    Set rs = New ADODB.Recordset
    sql = "SELECT ReadOrder FROM FinishReader WHERE MeetsID = " & lMeetID & " AND ReaderNum = " & sThisRdr
    rs.Open sql, conn, 1, 2
    lstPriority.Text = rs(0).Value
    Set rs = Nothing

Open in new window

This code only captures the first part of the page, I think because the whole page doesn't load until you scroll to the bottom of the page, which I don't know how to do programatically.

Set http = New WinHttpRequest

x = ""

http.Open "GET", x, "False"
myval = http.ResponseText

Open in new window

MSComm1.Output = "AT\n" & vbCrLf <br/>
Sleep 100<br/>
MSComm1.Output = "AT+CSCS=UCS2\n" & vbCrLf<br/>
Sleep 300<br/>
MSComm1.Output = "AT+CMGF=1\n" & vbCrLf<br/>
Sleep 400<br/>
MSComm1.Output = "AT+CSMP=17,168,0,8" & vbCrLf<br/>
Sleep 500<br/>
MSComm1.Output = "AT+CMGS=" & Chr(34) & Text1.Text & Chr(34) & vbCrLf<br/>
Sleep 600<br/>
MSComm1.Output = Trim(txtMsg) & " " & Chr(26)<br/>
MsgBox "MESSAGE SENT"<br/>
On Error GoTo p
MSComm1.Output = "AT\n" & vbCrLf
Sleep 100
MSComm1.Output = "AT+CSCS=UCS2\n" & vbCrLf
Sleep 300
MSComm1.Output = "AT+CMGF=1\n" & vbCrLf
Sleep 400
MSComm1.Output = "AT+CSMP=17,168,0,8" & vbCrLf
Sleep 500
MSComm1.Output = "AT+CMGS=" & Chr(34) & Text1.Text & Chr(34) & vbCrLf
Sleep 600
MSComm1.Output = Trim(txtMsg) & " " & Chr(26)
Sleep 700
setStatus "Done..."
Exit Sub
    MsgBox "Some Error Occured..." & Err.Description
End Sub

in the above example of visual basic 6.0 i have sending sms with gsm modem in AT commands but when I need to send sms in unicode this code gives receiver mobile a ???? format sms what is the solution
I had this question after viewing Locating ClientCertificate to use in WinHTTP.

Similar question, when using the SetClientCertificate property on a WinHttpRequest, I receive a "Certifcate is required to complete client authentication". The certificate has been created successfully, and appears in the Certifcate Store under Console Root -> Certificates (Local Machine) -> Personal -> Certificates.

The Issued to is ABC Certificate, the Friendly name is ABC

The parameters I am using are as follows:

myMSXML.SetClientCertificate "LOCAL_MACHINE\\Personal\\ABC"

I've tried ABC Certificate etc... tried putting the certificate in different stores, tried a number of other things, but still getting same message returned.

How did you go with your problem referencing a certificate in the Cert Store?
Big Business Goals? Which KPIs Will Help You
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.


This is a follow-up to another thread located here:

Create an executable file to open a non-executable file

In that thread, expert Joe Winograd provided a solution which involves creating an AutoHotkey (ahk) "Run" command (which I know how to do) then compiling the resulting .ahk file to create an .exe file. That was a great solution and I'm glad to now know how to do that. However, since closing the previous thread, I've realized that that solution is not practical for the specific purpose* that prompted my question.

As a result, I'm back to my original question which is:

How do you directly create an executable file (.exe or .cmd) to open a non-executable file (.xlsm, .txt, .ahk, etc)?

In the previous thread, expert tuvi suggested putting the following in a .cmd file:

start C:\Users\UserName\FolderName\FileName.xlsm

Open in new window

Unfortunately, while I know how to place a command in the cmd/prompt/DOS window (not sure what it's called), I do not know how to create a .cmd or .exe file. I tried simply pasting the above line in a Notepad window then saving it, first with a .cmd extension and then with an .exe extension but neither of those worked.

It seems like something I should know how to do but that's why I'm happy all of you great experts are available to answer questions. :)

Does anyone know of resources either in books or on the web, or does anyone have experience of using SCSI Pass Through / Direct using (ideally VB6).
I am interested in how to set up the IOCTL_SCSI_PASS_THROUGH / DIRECT without using .net I have tried some sample .net code and it is clunky and very slow.
Trying to get a session code response from the Betfair site using VB6. My software, which I've written and been using in a particular industry for 20 years, therefore huge amount of code, so trying to do it through VB6, and I've done other XML feeds using the Web Service, which are working really well.

So.... the issue is, i make a call to the site, and the return I get is HTTP ERROR CODE 400 through the response text.

Part of the process, required I create a certificate, using OPENSSL , which worked fine, and the certificate uploaded to my test account on Betfair, and the account has been enabled for access. I've also sent the P12 Key to my certificate store on my local Windows 7 (32 Bit) development computer, which allowed the call to go through without any "Certificate Required" prompts, so appears to get through that part. However, once through the response coming back is "HTTP ERROR CODE 400", in the response text. So it's not making my code fall over in any way, just not returning a session key, which is obviously required to proceed further.

The code is as follows, of which a username and password string is passed to the function from a login form.

Public Function GetBetfairSessionID(sUserName As String, sPassword As String) As BetfairSessionInfo
    Dim AuthURL As String

    AuthURL = ""
    Set myMSXML = CreateObject("MSXML2.ServerXMLHTTP")

Open in new window

I have a network, SCCM and end user requirement that demand the following actions from an Application/Deploy.

1)  When end users runs Cisco AnyConnect from Software Center, SCCM runs VB script that prompts them to continue or cancel and run at another time.
2)  If they chose to continue, VB script calls a batch file that checks for an existing file, copies one there if it doesn't exist, runs an MSI install for Cisco AnyConnect.

The scripts are now running as designed and successfully installing Cisco AnyConnect however,  Software Center is showing the install as failed - the error is 0x87D00324(-2016410844) which is usually detection method issues.  The detection method I'm using works at the beginning of the install or "Install" wouldn't be available.  The logs show that the last check for the installed version seems to be failing.  How is this possible if the application successfully installs?

    Matched exit code 0 to a Success entry in exit codes table.      AppEnforce      8/20/2018 11:22:14 AM      9892 (0x26A4)
    Performing detection of app deployment type Install(ScopeId_8D979019-6A8D-4166-A6B5-7321FD9A126B/DeploymentType_df8b95c0-b12f-4b9c-b456-4e2e8ef52e72, revision 36) for system.      AppEnforce      8/20/2018 11:22:14 AM      9892 (0x26A4)
+++ Application not discovered. [AppDT Id: ScopeId_8D979019-6A8D-4166-A6B5-7321FD9A126B/DeploymentType_df8b95c0-b12f-4b9c-b456-4e2e8ef52e72, Revision: 36]      AppEnforce      8/20/2018 11:22:14 AM      9892 (0x26A4)
++++++ App enforcement completed (15 …
I am using Access 2013 with Windows 8.1 and a Zebra desktop label printer Model 450 and model 505.
My printers are attached to my desktop on USB001 and USB003.
I have a label file that I have downloaded from FedEx. It is in ZPLII (ZPL2 is what FedEx calls it) format and I use the Extension .ZPL
The file is correct. I can go to and view the label to ensure it is correctly formatted and looks correct.
PROBLEM:  I cannot get the label to print in code. I have tried DOS using NET USE and redirecting my USBs to LPTs. I have tried using the network name after sharing the printer.
I have tried using copy and copy/b (for binary).  I know this must be just a few lines of code, but after hours and hours, I still can't get it to work.
If there was a desktop viewer for ZPL files, I could shell execute and run that program with a command line parameter, but no desktop viewer exist.
I have put just some of my trial code below, but nothing works.  Please help. Thank you.

'Open "USB001" For Output As #1
'Open "LPT1:" For Output As #1
' or open "COM1:"
'Print #1, "C:\Users\ISaunders\Documents\Quality Chemical\RateResponse.zpl"
'Close #1

Dim ItemName, ItemNum, ClassID
ItemName = "Expresso"
ItemNum = 142222
ClassID = "Coffee"
Open "\\IraDellLaptop\ZebraZP" For Output As #1
'Open "LPT3:" For Output As #1
Print #1, ItemName & " " & ItemNum & " " & ClassID
Print #1, "C:\Users\ISaunders\Documents\Access
Sub Link()

Dim Turbidity As Long
Dim RawTurbidity As Range

'Sets variables Turbidity being the ActiveCell and RawTurbidity refering to the last captured cell in raw sheets'
Turbidity = ActiveCell.Row
Set RawTurbidity = Sheets("Raw Data").Range("C4").End(xlDown)

'The formula assiging the last captured cell in Raw sheets to the active cell'
Sheet1.Cells(Turbidity, 4).Value = RawTurbidity.Value
End Sub

Open in new window

This is my code and it does pretty much what I want it to do. I have an instrument that spits data into column C in Raw Data sheet. What this macro does is copy that data into column D in Sheet1. I have another small Macro running on Raw Data that calls this macro whenever a change is made in column C in RawData and that's what activates this macro. Anyway what I'm trying to do is after the calculations have been copied to have the activecell automatically go to the next row just like pressing enter when your in a cell. Typically ActiveCell.Offset(1,0).Select would be the line for that. For some reason when I add that to the end of the macro it copies the data into the next four rows.

In case you were wondering the analyst don't do the analysis on sheet1 in order hence why I had to have Raw Turbidity copied into the activecell instead of just doing the available blank line.
I have a function that makes my .doc lose functionality, but it works for me in .dotm...
The function is "ActivateReferenceLibrary"; it runs on both the "Document_New" and "Document_Open" stage.
I know it is this function that is causing the issue because when I comment out the call function for it everything works.

Any ideas as to why this is happening? What am I doing wrong?



Sub ActivateReferenceLibrary() 'Activate Specific Object Libraries via GUID #

  Dim chkRef As Variant
  Dim BoolExists As Boolean
    On Error Resume Next
    For Each chkRef In VBProject.References
        If chkRef.GUID = "{00062FFF-0000-0000-C000-000000000046}" Then
            BoolExists = True
            GoTo Cleanup
        End If

    If BoolExists = True Then
        Exit Sub
        VBProject.References.AddFromGuid GUID:="{00062FFF-0000-0000-C000-000000000046}", Major:=0, Minor:=0 'This is Outlook GUID
    End If
End Sub

I am trying to write a code that allows me to open file explorer and import a .csv file, but I only need the data from cells A57 and B57 down until there is no more data. I would need that data imported to the active macro into cells A31 and B31. I have attached my current code that allows me to open file explorer, but I cannot copy and paste the data.

Thanks for the help!
Hello Sir,

looking for formula for switch result or value, Attached file FYI

result should be here is as if chose A then only shows M6:M14 & if is chose B then shows M16:M25 & if either one in not matched then Error
Starting with Angular 5
LVL 12
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

I am having a java application with source code and libraries.

I would like to convert the entire java source to DART. Basically wants to convert the java application to DART Application (Java flavour) -

Can someone help me what would be the easiest way or best approach or ways to quickly convert a java project to DART project ???

All the functionalities are same and no change in the functionality of the appplication.
I had this question after viewing ShellExecute Issue within VB6 on Windows 8.

Sadly we still have to use VB6, we have an application thats over 7 years old and just cant be ported to the new versions of VB, everytime we try we have to go from VB6, to VB8, then to Vb10, then to Vb12 - just a nightmare and the app has some 20 odd bespoke ocx's in it, some 70 forms, and an enormous amount of coding.

The problem we are having, and i know its getting worse, we need to open a file using the associated program.

OpenWithDefault = (ShellExecute(0&, "", FileName, vbNullString, vbNullString, SW_SHOWNORMAL) > 32)

This will work on some windows pcs, not others, some are 64 bit others arn't, some are windows 8 some are windows 10.

Whilst i understand its the UAC - how do i get round it ?

On a windows 10 64 - works no problem, on a windows 8 64 - no probs, on another windows8 64 - wont work but it will open pdfs, word docs, just not TEXT files ?

On windows 7 both 32 & 64 - everything opens

Anyone got any solutions and please dont say just upgrade, i cant upgrade 7 years worth of progamming over night - no chance !

All the new apps, we use the newer versions when we can, but its not an option to upgrade this application.

Any help would truely be appricated.



I am trying to open a PDF, copy all the contents and paste as picture into Word, using VBA.

I got this code:

    Dim AdobeLoc As Variant
    Dim appAdobe As Variant
    Dim rng As Range

    set rng =  Doc.Bookmarks("Bookmark1").Range      ' I am opening the document earlier

    AdobeLoc = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"

    appAdobe = Shell("" & AdobeLoc & " " & strPath & "Test.pdf" & "", 1)

     AppActivate "Acrobat Reader DC", True
     SendKeys "^a"
     SendKeys "^c"

My problem is the SendKeys "^a" copies not from PDF, but from Word Document. How do I do this?

is it possible to create a spreadsheet which will automatically assign date and time in one cell on the action?
I would like to scan a barcode in cell A1 and when I scan, excel will automatically assign date and time (with minutes and seconds if can) of that scan in cell B1. So I can track when was each scan created or scanned.
Also, is it possible to create VBA scrips where that Excel spreadsheet will automatically on a predefined time in a day do file/save as on specific folder in Desktop?
Thanks in advance.
I would like to have a complete code that reproduces. avi files in the. dll. OCX and other files in a PictureBox written in Visual Basic 2010 Express.
So to speak for example that it reproduces an AVI file while it is copying a file (I have the code in Visual Basic 6 I enclose and I cannot get it to work in Visual Basic 2010 Express).
From what I could understand by reading the various forums in Internet there is also the possibility of embedding an AVI file by transforming it into a resource and uploading it to Visual Basic 10 Express, if it were so it would be good to know how to create that resource, embed it in Visual Basic 10 Express and play it in a picture box while the application is working (always with full code).
is clear transparency effect and continuous play.
I would want complete code to download with any clarifications.
I am an Access programmer. I posted a question to convert access application to web based.  Now I am planning to move to web development. I came to know there is no way you can convert or move directly to web based programs.
I appreciate if you show some guidelines to start a web program (as if I am new to development).
Appreciate your help.

Visual Basic Classic





Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.