Visual Basic Classic




Articles & Videos



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

Hi Experts,

I realized that MSFT changed the way it was handling combo boxes that were not selected any values, up till version 2007 the it was considered null, and the function IsNull(myComboBox) returned true, while IsEmpty(myComboBox) returned false, and from version 2010 its the opposite, Isnull is false and IsEmpty is true.

Now I'm used to have nz(MyComboBox,FillInValue) working fine and now that does return the FillInValue anymore, I guess its due to the above.

Now my question.
Did you also experienced that behavior?
What is the alternative to the NZ function? (Besides for having to use the IIF() function which will make things slower IMO).

Thanks in advance.
On Demand Webinar - Networking for the Cloud Era
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button


This is another in a series of questions I have posted recently to come up with Excel VBA code that will selectively reformat a specified string (or strings) of text within a cell, but not the entire cell.

For example, suppose you wanted to reformat a sentence in cell B2 to that shown in D2:

Note that the particular formats shown in this screenshot are arbitrary as the main objective is to have a code which can apply any desired formatting.

I have a dropdownlist that a user can select their system trouble shooting problem with. Once they select the problem I want the solution to be shown in a label..please am using vb6.0
I am using WinHttpReq. to download a CSV file to import into one of my Access projects.
I use this code to retrieve,

Public Sub GetUCFiles(myUrl As String, OutputFile As String)
Dim WinHttpReq As Object
Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "GET", myUrl, False, "username", "password"

myUrl = WinHttpReq.responseBody
If WinHttpReq.Status = 200 Then
    Set oStream = CreateObject("ADODB.Stream")
    oStream.Type = 1
    oStream.Write WinHttpReq.responseBody
    oStream.SaveToFile OutputFile, 2 ' 1 = no overwrite, 2 = overwrite
End If
End Sub

Open in new window

I use this to call it

filein = DLookup("Path_Local_Data_Report", "Admin", "ID=5") 
        FileOut = vardirectory & "\Occupation.csv"
        Call GetUCFiles(filein, FileOut)

Public Function vardirectory() As String
If TempVars("OSver") = 5 Then
        vardirectory = Environ("USERPROFILE") & "\My Documents\Downloads"
        End If
            If TempVars("OSver") = 6 Then
            vardirectory = Environ("USERPROFILE") & "\Downloads"
            End If
End Function

Open in new window

Everything works perfect for the first time. If something changes on the remote side, this code wont download a current updated CSV file
unless I restart my Access project.

Anyone had this happen before?

Hi Guys,
I have aspx page that have textbox controller and listbox controller in my page:
<asp:TextBox ID="txtObject" onfocus=";" runat="server" AutoPostBack="True" CssClass="form-control"></asp:TextBox>
<asp:ListBox Style="border: none; min-height: 350px;" Width="100%" ID="lstTracked" runat="server"></asp:ListBox>

Open in new window

Now, when I type some text on the textbox and enter it is inserting the text to the lstbox and so on, but in some point after I enter 3 4 and sometimes 10 entries I'm getting error:

Here is the error:
Source:      System.Web
Description:      Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Source:      Void ValidateEvent(System.String, System.String)
Data:      at System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) at System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) at System.Web.UI.WebControls.ListBox.LoadPostData(String postDataKey, NameValueCollection postCollection) at System.Web.UI.WebControls.ListBox.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, …
I have this code which will find matching sets of three numbers (and colour them for ID) across a worksheet. (sample sheet attached 007-quad-ID-query-ee.xls )

Could it be adjusted to find those sets of three numbers which match 5 or more times ?
Code :

Option Explicit

Private Type Sets
    strAddr As String
    strCells As String
    lngColor As Long
End Type

Sub IdentifyDuplicates()

    Dim lngLastRow As Long
    Dim lngLastColumn As Long
    Dim lngRow As Long
    Dim lngCol As Long
    Dim DupeSets() As Sets
    Dim strSet As String
    Dim lngFind As Long
    Dim lngFound As Long
    Dim lngColors()
    Dim lngNextColor As Long

    lngColors = Array(13494512, 11599871, 13626575, 15723724, 15258845, 12178907, 8518399, 11461045, 14667418, 14136257, 10074816, 5369343, 9491089, 14071663, 12683685, 13233150, 11596768, 14541491, 15259071, 15654653, 10668797, 7791807, 12504966, 13674644, 13743867, 8759804, 6146693, 10728776, 12552565, 11963641, vbYellow)
    lngNextColor = 0

    ReDim DupeSets(0)
    lngLastRow = Range("A65536").End(xlUp).Row
    lngLastColumn = Cells.Find("*", SearchOrder:=xlByColumns, LookIn:=xlValues, SearchDirection:=xlPrevious).Column

    For lngRow = 4 To lngLastRow
        If Cells(lngRow, 1) <> "" Then
            For lngCol = 8 To lngLastColumn Step 4
                strSet = Cells(lngRow, lngCol) & "," & Cells(lngRow, lngCol + 1) & "," & Cells(lngRow, lngCol + 2)
I have this code which sorts groups of 6 numbers into all possible sets of 3 (of which there are 20)

Could someone help and alter it so that it sorts 6 numbers into all possible sets of five please ?

Public Sub Triples()
    intNumbers = 6
    Set wsData = ThisWorkbook.Worksheets("Sheet1")
    For rowCurrent = 4 To wsData.Cells(wsData.Rows.Count, 1).End(xlUp).Row
        colOutput = 8
        For i1 = 1 To intNumbers - 2
            For i2 = i1 + 1 To intNumbers - 1
                For i3 = i2 + 1 To intNumbers
                    wsData.Cells(rowCurrent, colOutput).Value = wsData.Cells(rowCurrent, i1).Value
                    wsData.Cells(rowCurrent, colOutput + 1).Value = wsData.Cells(rowCurrent, i2).Value
                    wsData.Cells(rowCurrent, colOutput + 2).Value = wsData.Cells(rowCurrent, i3).Value
                    wsData.Cells(rowCurrent, colOutput + 3).Value = ""
                    colOutput = colOutput + 4
End Sub
Hi. I am using the Bloomberg COM v3 Data Control code in their RefDataExample.xls to retrieve BID and LAST_PRICE_TIME_TODAY for a list of bond ISINs. I need the data to be returned in the same row as the ISIN for which the request has been made. However, if a bad ISIN is in the list the results seem to be returned in a fairly random way. If I then do nothing else but rerun the macro the order of the returned data changes. I am not an expert. Anyone got any bright ideas? Thank you very much.
The problem is best seen by using simple numbers for the ISIN input column of 1 to, say, 100 and seeing how the output is returned to the right of the input column.
This has been answered by Bberg now. Thanks
I have an application running in classic ASP coding with HTML pages and in one .asp page the client requested for a button. This button when clicked, it must export whatever the data present in Table of Access database (already in use) to an excel sheet. Kindly help as i have been searching for this sort of code everywhere.

I'm aware that various parts of an Excel window (eg gridlines, headings, Formula bar, etc) can be hidden using the View menu and other parts (sheet tabs, scrollbars, etc) can be hidden by going to: File > Options > Advanced.

Recently I came across a thread in Mr. Excel which includes a post (by none other than prolific EE expert Rory Archibald) showing VBA code for how to display the Status Bar in Excel:

application.DisplayStatusBar = True

Open in new window

I actually wanted to hide the Status Bar so I inserted:

application.DisplayStatusBar = False

Open in new window

which worked.

Now I'm wondering what other parts of an Excel (or other app) window can also be hidden using VBA. For example, is it possible to hide the Title bar, Ribbon and/or Quick Access Toolbar in a similar way? If so, can someone post the code?

Online Training Solution
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Hi All,

Have a problem and need help here. i am using vb6 and now face 2 problem .
1. Need to split the string into variable from CSV file but the data may contain comma in quote, which is -
            - string = abc,"3,4,5,6","3",Steve,got,"1,2,3",problem
             * i want to split into 6 variable to become
                aVar = "abc"
                bVar = "3,4,5,6"
                cVar = "3"
                dVar = "Steve"
                eVar = "got"
                fVar = "1,2,3"
                gVar = "problem"

2. i want to sort the string in 2 element, which is sort bVar then follow by fVar.

Anyone able to advice,

thanks in advance.

Hi guys,

I'm trying copy a file from one folder to another but get a permission error, how come? If i do it manually it works just fine.

here is my code:
Function Recurse(sPath As String) As String

    Dim fso As New FileSystemObject
    Dim myFolder As folder
    Dim mySubFolder As folder
    Dim myFile As file

    Set myFolder = fso.GetFolder(sPath)

    For Each mySubFolder In myFolder.SubFolders
        For Each myFile In mySubFolder.Files
            'If myFile.Name = Range("B1").Value Then
            If myFile.Name = "SHB_Addins ver 1.7.dotm" Then
                Debug.Print myFile.Name & " in " & myFile.path 'Or do whatever you want with the file
                Debug.Print mySubFolder.path
                Call fso.CopyFile("S:\Udvikling\Addin\I prod\SHB_Addins ver 1.8.dotm", mySubFolder.path)
                Exit For
            End If
        Recurse = Recurse(mySubFolder.path)

End Function

Sub TestR()

    Call Recurse("\\bfd2\b00037\Templates_master\")

End Sub

Open in new window

Please note, i am getting an error after Call oUIDoc.FieldSetText("EnterSendTo", stTo).
 Run-time error 2147417851,Automation Error The server threw an exception

Please assist in stTo ie "Const stTo As String = "V/India/IBM"" What should i write instead of this
is it possible to programatically create a computer to computer voice chat using classic vb or through internet?

e.g. suppose two computers A in UK and B in USA
computer A is a server  which is connected to a client computer B
at the same time
computer B is a server  which is connected to a client computer A

the user on Computer A Sayes: hellow
    1- the sound is converted to a file (..wav)
    2- the wav file is immediatly sent to computer B winsock
    3- Computer B winsock recieves and play the voice
the user on Computer B Sayes: How Can I help
    1- the sound is converted to a file (..wav)
    2- the file is immediatly send to computer A winsock
    3- Computer A winsock recieves and play the voice
and so on

Because both are servers and clients at the same time then they can both talk at the same time and also listen.

or may be there is a tool better that winsock that does the job, open channel and deal with the voice .....
Hey guys,

I have a report on Excel that is linked to a specific Powerpoint presentation, and as the Excel file is frequently updated with new data, I would like to add a VBA code in order to:

1. Open the wanted Powerpoint file
2. Update all the links
3. Break all the links
4. Save the Powerpoint presentation as a new & separate file

This way I can easily send those reports quickly without having to change the original PPT file.

I'm pretty new in the VBA world so any help will be HUGELY appreciated :)

Many thanks!!
Hi all...
I'm new to programing and encryptation...
I need to encrypt the contend of a file, i had a look on the net and found 2 functions:
1° Uses RijndaelManaged, SHA512, with password, salt, hash
2° Uses RijndaelManaged, MD5CryptoServiceProvider with password

Mi question is if i encrypr the contends of the file with the first one, the convert encrypted to Hexadecimal and encrypt again with the second one will it easy to crack it?
I dont know if it makes sence or if i m saying it something realy stupid but...

Thanks in advance

I'm trying to write a code to add appointments to several outlook shared calendars but it is not working. Everytime shows up a error automatation message. I believe that it has to be something with accessing to the shared calendar but I'm stocked on it. I will appreciate your help:

Public Sub CreateOutlookApptz()
   ' On Error GoTo Err_Execute
    Dim olApp As Outlook.Application
    Dim olAppt As Outlook.AppointmentItem
    Dim blnCreated As Boolean
    Dim CalFolder As Outlook.MAPIFolder
    Dim subFolder As Outlook.MAPIFolder
    Dim arrCal As String
    Dim NS As Outlook.Namespace
    Dim objOwner As Outlook.Recipient
    Dim newCalFolder As Outlook.Folder
    Dim i As Long
    On Error Resume Next
    Set olApp = Outlook.Application
    If olApp Is Nothing Then
        Set olApp = Outlook.Application
         blnCreated = True
        blnCreated = False
    End If
    On Error GoTo 0
    'opcion 2
    Set NS = olApp.GetNamespace("MAPI")
    Set objOwner = NS.CreateRecipient("")
        If objOwner.Resolved Then
        MsgBox objOwner.Name
        Set newCalFolder = NS.GetSharedDefaultFolder(objOwner, olFolderCalendar)
        End If

    i = 4
    Do Until Trim(Cells(i, 1).Value) = ""
    arrCal = Cells(i, 1).Value
    Set subFolder = newCalFolder.Folders(arrCal)
    If Trim(Cells(i, 11).Value) = "" Then


Open in new window

Dim PubApp As Object
    Set PubApp = Publisher.Application
    PubApp.Open "C:\Users\David\Documents\............"
     PubApp.Visible = True
I could install a desktop icon for my program, but don't know how to tell the uninstaller to remove it when uninstalling my program. I am using VB6. Someone please help me, it seems the VB6 Package and Deployment does not have this function. Thanks..
Free Tool: SSL Checker
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


We have In House Team Foundation Server (2010) for Source control

I am planning to upgrade entire development on Cloud / Hybrid.  

How easy to migrate TFS2010 on Visual Studio Team Services on Cloud?  Will it migrate entire History and also include legacy projects?
How about team members, which are now controlled through Active Directory (Domain Network)

Has anyone done this before, could you please suggest a detailed plan?

Thanks in advance

Best regards
Hi Experts,

This issue relates to one of our VB6 applications that is installed on dozens of user PCs.

We are using DAO 3.6.

One user has just installed the application on a Windows 10 PC and has reported this issue.

We have checked that his .mdb files work fine at our end.

Hi! I use mjwPDF  in VB6   to create pdf file.  Can you give me a code for align text in pdf file? I import text from textbox with multiline.
HI! I want to save to file PDF in VB6  many textbox. Some textbox are multiline but mjwPDF Not recognize VbCrLf.  Can you help me? The text in PDF created  apear on the same line, but in textbox is multiline
I have an iSeries PF file containing several records.  In order for the individual records to be imported into an imaging system, I need to be able to output each individual record to a file and then download the file either to a pdf or Excel format.  The file name for each record needs to contain it's key structure.  Is there a way to do this?
trying to insert signature box in microsoft access form. this will help me take customer signatures once task is complete.
code was purchased online - but cant integrate this functioaanlity in microsoft access db.
on "accept button" it gives me error code " Compile error User-defined type not defined" highlights the code line
"Dim objInk AS MSINKAUTLib.InkPicture"
let me know if you require any more information that will help u help me.

thank you.

Visual Basic Classic




Articles & Videos



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.