[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More


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

I am developing an employee database. I added all employees to an organisational unit (department etc) - and each organisational unit belongs to another organisational unit, except for the top one which is blank; the CEO. With a self-join, I can then create a hierarchy once all the data has been added.


I tried creating a function which would populate a collection from the uppermost organisational unit (the CEO) all the way down and I used recursions to traverse the tree.

Function preorderProcessing(parentID As Integer)

    Dim MyDB            As DAO.Database
    Dim MyRS            As DAO.Recordset
    Dim x               As Integer
    Set MyDB = CurrentDb()
    Dim qdf As DAO.QueryDef
    Set colOrgUnits = New Collection
    If parentID = 0 Then
        Set qdf = MyDB.QueryDefs("qyrOrgUnits_SearchParentID_Null")
        Set qdf = MyDB.QueryDefs("qryOrgUnits_SearchParentID")
        qdf.Parameters("parentID") = parentID
    End If
    Dim rs As DAO.Recordset
    Set rs = qdf.OpenRecordset
    Do While Not rs.EOF
      colOrgUnits.Add (rs.Fields("org_OrganisationUnitID"))
    Debug.Print "Now checking units: "
    For x = 1 To colOrgUnits.Count
        Debug.Print "In this stack: " & colOrgUnits.Item(x)
    Next x
    Debug.Print "COUNT: " & colOrgUnits.Count
    If colOrgUnits.Count > 0 Then
        For x = 1 To colOrgUnits.Count

Open in new window

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!

Hi Experts,
Is there a way to use a single keyboard key to perform the following?
Shift-F8      Step over the line by running the procedure on the current line without going into it and stepping through each line
Hi Experts

I am using Redemption to send emails from an Access 2003 database. This has been working fantastically...until now. This morning when trying to send emails we all get the circle of death and have to kill the program. I then went on to purchase the latest Redemption version thinking this will fix the problem. This however made it worse and threw errors when trying to open the database.

Does anyone have any experience using Redemption and can help me with fixing this problem?

Thank you

I have discovered a dilemma with our azure SQL database. Under firewall settings I am supposed to specify IP addresses that can access the database. We are using a VB6 app, which is not central to any specific location. Is it OK to open up the firewall so that various locations can access it? Or is this too much of a security risk? Has anyone ever run into this problem?

I need your help on a macro. I copy from a website a latitude / longitude in this format: "47.123456;-79.987654"

What i'm trying to do is to paste the latitude in the Latitude Textbox and the Longitude in the Longitude Texbox.

So the delimiter will be: ";". The reason is that the number of digits after the decimal can vary.

So in Longitude Textbox, i will have: "47.123456"
In Longitude Textbox i will have: "-79.987654"

Paste value
Then, the final touch will be to only keep the 4 last digits after decimal in each textbox. The value cannot be rounded. It must keep the exact same 4 digits after decimal.

I'm adding a project sample where you can copy to clipboard a latitude and longitude. Then when you click on Paste Latitude and Longitude, it should update the proper Textbox.

How can i do that?

Thank you for your help.
Lookup Error when search value is not foundDrop Down LookupHi,

  In my  ACCESS database, I have a table where I store company names and passwords.
 and form where I have two records - "AAA" and "CBS" . When searching for the record, if I enter non-matching value, then I get an error.
  Getting an error is ok, but it does not have what I call "graceful exit".
  For example, if I am typing "ab" and press [enter], I get an error message (as seen in the screenshot).
  What kind of visual basic code can I use to provide a graceful exit?

I have a website hosted by WIX which does not allow me to put a .txt version file on their site.  Previously my app would check to see what current version was listed in the text file before applying an update.  I was thinking about putting the version number on a web page but the question is how would I read the webpage using vb6?  What would be the proper syntax?

Here is what I used to use:

[code]'Checking for latest version-----------------------------
cdata = Inet1.OpenURL("www.wxxxxx.org/version.txt", 0)

If cdata > 27.6 Then[/code]
Hello experts,

I am looking for a solution to re-use macros in new presentation.
This can be done through Personal.xlsb file in Excel, however this option is not available in powerpoint.

What do you recommend for this?

Thank you in advance for your hel
Hello experts,

I have the following procedure in order to reset & delete the various guides.
Sub DeleteGuides()
    With ActivePresentation.Guides
        ' Delete the second guide
    End With
End Sub

Open in new window

However when I launch it, I am not able to reset all of guides

Could you please  help me to adjust?

Thank you in advance for your help.
Hi Experts,

I'm looking to create a VBA function that will accept a file name as a string parameter, then rename a file as follows.
if parameter is "Skilled_Nursing_Visit_Note" then will look at given folder for file starting with that name for example "Skilled_Nursing_Visit_Note_2018-Nov-26_1901.csv"
and rename that file to just "Skilled_Nursing_Visit_Note.csv", in other words, remove the date/time and sequence timestamp from that file name.

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.

How do I convert these properties and such from vb6 to vb.net or c# prefably. Thank you.

Public Property Let Confirmed(Index As Integer, bConfirmed As Boolean)
    If bConfirmed Then
        sTransferOrder_Items(Index, GI_CONF_TO_ITEM_CONFIRMED) = vbChecked
        sTransferOrder_Items(Index, GI_CONF_TO_ITEM_CONFIRMED) = vbUnchecked
    End If
End Property
Public Property Get Confirmed(Index As Integer) As Boolean
    Confirmed = (sTransferOrder_Items(Index, GI_CONF_TO_ITEM_CONFIRMED) = vbChecked)
End Property
Hello Experts,
This is a VB6 very small app that has been working fine for decades
the nice things users like about it are that it shows a percentage number when transmitting... and its pretty fast.

For some reason, it started showing the following message
" 503 This system is not configured to relay sender from an anonymous sender. "

Please your advice,
I am trying to enter a SUM formula to a table in a Microsoft word document using VB6.  Does anyone know the syntax for doing that?
Hi Experts,
Looking for a script that will perform the following
open a given spreadsheet, loop thru all columns/rows and replace all data as follows. (except for first row)
for every character found, replace it with letter A
for every digit found, replace it with 1
should leave any special character like slashes or space intact.
I have a Word document and placed text boxes in corresponding fields as you
can see in the attachment.  What I am trying to do is take data and put them
into those text fields.  Using VB6 I am trying to figure out what the
correct syntax is to place data in a text field AND also a table in
Microsoft Word.  I believe there might be a use of bookmarks but I can't
remember. Your help is appreciated.

[code]Set objMSWord = CreateObject("Word.Application")

Set myDOc = myWOrd.Documents.Add()

Dim oTable As Word.Table
Dim Para1 As Word.Paragraph[/code]

myDOc.Sentences.Last.Text = "This is a test "

'What is the correct syntax to place data into a textbox field in Microsoft
[embed=doc 1403738]
I need a copy of msflxgrd.ocx verion   I have msflxgrd.ocx version but my Security Vulnerability Check states that I need version
This is a 32 bit version.

The required MS updates state that I need VB 6.0 installed.
Dear all,

I would like to hear from you some ideas on how make "Deep Document Summarization: Combining Text and Images" besides extracting paragraphs. And if PHP it is an appropriate language for doing this task

I am looking for ideas and suggestions

I would like to get some information from outlook. Basically, get the number of emails received every month, but not just for the current view (this is what my code does right now, fut for all subfolders, up to 2 depth). I have tried with this:

'The following codes are working to count by day
Sub CountReceivedEmailsbyDay()
    Dim objItems As Outlook.Items
    Dim objItem As Object
    Dim objMail As Outlook.MailItem
    Dim strMonth As String
    Dim dReceivedTime As Date
    Dim strReceivedDate As String
    Dim i, n As Long
    Dim strMsg As String
    Dim nPrompt As Integer
    Set objItems = Outlook.Application.ActiveExplorer.CurrentFolder.Items
    objItems.SetColumns ("ReceivedTime")
    strMonth = InputBox(“Enter the specific month.(Format: yyyy-mm)”, “Specify Month”)
    If strMonth <> "" Then
       n = 0
       For i = 1 To objItems.Count
           If objItems.Item(i).Class = olMail Then
              Set objMail = objItems.Item(i)
              dReceivedTime = objMail.ReceivedTime
              strReceivedDate = Year(dReceivedTime) & “-” & Month(dReceivedTime)
              If strReceivedDate = strMonth Then
                 n = n + 1
              End If
           End If
       Next i
       strMsg = "You have received " & n & " emails on " & strMonth & "."
       nPrompt = MsgBox(strMsg, vbExclamation, "Count Received Emails")
       nPrompt = MsgBox("Please input the specific month!", vbExclamation)
Hi Experts,
we have a site created in Caspio that has some required fields.
We realized that some of the required fields are coming thru w/o containing data.
So were told by Caspio that is probably due to those users using an old browser.
They created a field named user_agent that will capture which browser were used for each record data entry.
Now I created a list of all records with missing data in required field along with the data captured in this field named user_agent (browser).
See attached.
Wondering what are those values are and how can we sent a message informing this and this browser is not supported...
C++ 11 Fundamentals
LVL 12
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Hi Experts,

I have the following code which loops thru all fields from a text data file (csv), reads the value and constructs a string.
Would like to have the following modification.
For each field containing a date/time value, check if the time is midnight like "2018-08-01 00:00", in that case should change the time to either 24:00 or 00:00 AM

For Each ColumnName In columnsName

                    fieldName = Replace(ColumnName, " ", "")

                    fieldValue = Mid(columns(c), 2, Len(columns(c)) - 2)

                    patient(fieldName) = fieldValue

                    c = c + 1

objHTTP.SetTimeouts 0, 0, -1, -1
objHTTP.Send JsonConverter.ConvertToJson(patient)

Open in new window

Wanted to replace data from one column to another.

For example:
On the "OPEN" Tab - On column AB if there is something there then that should go to column J and what's in Column J should be in Column K.  The end result should look like what's in the "SHOULD BE" tab.  This should only happen when there is something in column AB

See attachment.
Hi Experts,

I have attached a VB Utility being regularly used by me. It is used to prepare some returns, where we input the data and the output is produced in the shape of some encrypted file format for onward submission. But it can also be used to prepare a correction return also. In that case we need to import a Consolidated file and then the return can be amended or extended.

What I presently do
--Download all the conso files

--Import the files one by one in above software.
>>Here we need to Select Form No (24Q / 26Q / 27Q / 27EQ).
>>Type of statement to be prepared is always "Correction".
>>Option to be selected "Import Consolidated File"

--Copy the data from the tabs and paste them in different sheets of Excel (Normally there are 3 Tabs, but data from 1st Tab is never copy pasted. There may be 4 tabs for the 24Q - 4th Quarter of a Financial year in which case the last 3 tabs are copy pasted)

Name of Tabs (from which data to be copied and pasted in Excel) in case of each Form
24Q >  Challan , Annexure I        (in case of 4th Quarter of FY tabs to be Copy pasted are Challan, Annexure I and Annexure II
26Q >  Challan , Annexure I
27Q >  Challan , Annexure I
2EEQ >Challan , Annexure I

Challan Data can be pasted in the same Excel Sheet for All Form Types, whereas for Annexure I and Annexure II, we need separate sheets for Each Form.

I wish some script (or anything like that even if that is in Excel) which can
These two lines of vb6 code I am trying to translate to C#:

mskFromDate.Text = Format(Date - TimeSerial((iNumDaysBefore * 24), 0, 0), "Short Date")
    mskToDate.Text = Format(Date + TimeSerial((iNumDaysAfter * 24), 0, 0), "Short Date")

I have this so far. I know it is not right.

var dt = string.Empty;
                dt = Convert.ToString(DateTime.Now.ToOADate() - (NumDaysBefore * 24));
                this.dtFromDate.Text = Convert.ToDateTime(dt).ToShortDateString();

Anybody have thoughts? I can't believe in vb6 they let folks subtract dates and numbers.
I have a VB script that I want to adapt to remove a desktop link from the currently logged on user's Desktop.  It isn't working and I get no error messages - no nothing.

On Error Resume Next
Dim FSO, WSHShell, Regkey, Username, strFolder, UserPath, objShell

Set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\"
Username = WSHShell.RegRead(RegKey & "LastLoggedOnSAMUser")
Username = Mid(Username,7) 

Set FSO = CreateObject("Scripting.FileSystemObject")
UserPath = "C:\Users\" & Username 
strFile = "C:\Users\" & Username & "\Desktop\CMS Supervisor*.lnk}" 
if FSO.FileExists(strFile) = True then  FSO.DeleteFile DesktopPath & "\CMS Supervisor*.lnk"

Open in new window

Hi All,
I have a C# DLL which was written for me to interface with my VB6 program.  The DLL is COM-Visible and the Register for COM interop selected.  The DLL has 3 methods Initialization, Up and Dn.

I have a small VB6 test program which access the DLL.

I'm using VS 2017 (run as administrator) to build the DLL
I have Visual Studio (VB6) on the same machine - A Windows 10 PRO system.

In my VB program I have a reference to the DLL (actually the TLB).  Intellesense works fine - I can see all three methods.
My startup code is:
Public Sub Main()
    Dim AM as AudioManager
    Set AM = New AudioManager       ' <<<==== Error here
End Sub

Open in new window

When I run the program I get an error at the Set statement - Runtime 429 - "ActiveX component can't create object".
I've done quite a bit of research on the web about this, and most of the similar issues are when someone tries to move a project from a development environment.  In my case , I'm getting this on the development system.
I have tried:
Tlbexp AM.DLL /out:AM.tlb
Regasm /tlb:AM.tlb AM.DLL
Gacutil /i AM.DLL
So far nothing seems to work.  I have put the DLL and TLB into the System32, SYSWOW64 and my VB6 application folders (registering it in each after removing from the previous location) - doesn't help.
Anyone have any ideas?
Thanks in advance

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.