Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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 have Windows 10 and need my old 32-bit VB6 projects to run and compile on this. I have read some articles saying that tweaks and tricks has to be done and I need someone that did this before, to help me, remote control my Win10 and install VB6 for me. Anyone?

I've read these:
On Demand Webinar: Networking for the Cloud Era
LVL 10
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Hi Experts,

Wondering if there is a way to prevent user from selecting all records in a continuous form and copying into memory?
PS, I can remove the copy/paste menus, however they can still use Cntrl+C to have that contents copied into memory

Thanks in advance.
This may be an obvious question to many, but I've tried multiple iterations and much internet searching and can't get this to work.  I basically want to ask the user to input a value and then use that value in a table with filters to filter the data using the input word.  Would appreciate any help.  My current attempt below.


Dim newVal

newVal = InputBox("Enter the search term")

If newVal = "" Then Exit Sub

Sheets("Question Database").Select
    ActiveSheet.ListObjects("RFPQs").Range.AutoFilter Field:=1, Criteria1:= _
        " & newVal & ", Operator:=xlAnd

Open in new window

this is my code and am sending get request using proxy how ever when i click the button the iu freezez please help.
is their a faster way without the ui freezing up ,  its only when proxy is used in winhttp it freeze  please help

RichTextBox1.Text = ""
Dim lngI As Long
For lngI = 0 To List1.ListCount - 1
If Combo1.ListIndex = Combo1.ListCount - 1 Then
        Combo1.ListIndex = 0
        Combo1.ListIndex = Combo1.ListIndex + 1
        Text2.Text = Combo1.Text
    End If
'       Text1.Text = ""
   Dim result As String
Dim url As String
Dim winHttpReq As Object
Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
url = ""
winHttpReq.Open "GET", url, False
'winHttpReq.SetRequestHeader "User-Agent", "SonyEricssonT618/R401 Profile/MIDP-1.0 Configuration/CLDC-1.0"
winHttpReq.SetRequestHeader "User-Agent", Text2.Text
winHttpReq.SetRequestHeader "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
winHttpReq.SetRequestHeader "Accept-Language", "en-US,en;q=0.8,en-us;q=0.5,en;q=0.3"
'winHttpReq.SetRequestHeader "Accept-Encoding", "gzip,deflate"
winHttpReq.SetRequestHeader "Accept-Charset", "windows-1251,utf-8;q=0.7,*;q=0.7"
winHttpReq.SetRequestHeader "Keep-Alive", "115"
winHttpReq.SetRequestHeader "Connection", "keep-alive"
winHttpReq.SetProxy 2, List1.List(lngI), ""
'result = winHttpReq.ResponseText
   'RichTextBox1.Text = RichTextBox1.Text & winHttpReq.Status & vbCrLf & 

Open in new window

I need to return a single character from a text string following "<Gender>", how can I do that? Thank you
Access 2013 and ASP Classic
New to Access, I have the database and an excel file on my server in the same folder.  I created a query that links to the excel sheet.  I then have a web page that allows users to sort / filter / search for products on the query, which is linked to the excel sheet.  It appears if I open the excel, it locks others from using the webpage.  You can see the webpage with the error I included in the title.  It was my understanding, that while I work on the excel sheet, it created a locked file for me, so that the webpage could still function?  The folder that has the database, is read/write permissions for a group of users. (100).
Here is my connection strings:
dim rsFieldOneObject
dim connectionStringToAccess
Set rsFieldOneObject = Server.CreateObject("ADODB.Recordset") 
Set connectionStringToAccess = Server.CreateObject ("ADODB.Connection")
connectionStringToAccess.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & server.mappath("db/matrix-1.accdb")       	

Open in new window

This is where it first tries to pull data:
                 dim objRs
		Set objRs = Server.CreateObject("ADODB.Recordset")
		dim sicSQL
		sicSQL= "Select distinct(SIC), SIC_Description from MaxtixTable2"
		objRs.Open sicSQL, connectionStringToAccess
		Response.Write "<select name='sicInput' required>"
		response.write " <option value='' selected> SIC Choice... </option>"

Open in new window

Then it loops thru the data to create a drop down of choices.

I am using the linked excel so a team of four can keep it updated with no experience in ... anything computers.
I hope to create a form for them to use in the future, but deadline for project is too close to do that right now.

Do I have to tell them not to do any updates to excel during normal operation hours?  or should the excel being opened create a locked version so that the users can still use the webpage?


I have devlopped a "library" (heavily object oriented) contained in an access database (let's call it IM), intended to be used (referenced) by other projects (wich users can install wherever they want).
For many reasons, I make an extensive use of late binding, cept on the IM database itself.
I tryed setting a reference dynamically, that turned out to be a nightmare to manage (reference broken, name already used and so on ...)

Is it possible to late bind on the IM database ?
Or are there any better solution ?

Client code will need to either instanciate classes or use utility fonctions from IM database.
I saw about using the function, but it only work for procedures, and return no value, wich isn't my need.

Thanks for your replies.
Thanks in advance...
I have a code sequence that scrolls through my outlook contacts and updates all that have been edited or added since the last update was run

It doe this by saving the last uodate and only editing contacts that have a creation date or a lost modification date after the saved date.

The process takes some time (6,000 + contacts)

Is there a way to "filter" the contacts folder and only scroll through those that have a creation date or a lost modification date after the saved date
Option Explicit

Private Type DOCINFO
  pDocName As String
  pOutputFile As String
  pDatatype As String
End Type

Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal _
    hPrinter As Long) As Long
Private Declare Function EndDocPrinter Lib "winspool.drv" (ByVal _
    hPrinter As Long) As Long
Private Declare Function EndPagePrinter Lib "winspool.drv" (ByVal _
    hPrinter As Long) As Long
Private Declare Function OpenPrinter Lib "winspool.drv" Alias _
    "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, _
    ByVal pDefault As Long) As Long
Private Declare Function StartDocPrinter Lib "winspool.drv" Alias _
    "StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, _
    pDocInfo As DOCINFO) As Long
Private Declare Function StartPagePrinter Lib "winspool.drv" (ByVal _
    hPrinter As Long) As Long
Private Declare Function WritePrinter Lib "winspool.drv" (ByVal _
    hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, _
    pcWritten As Long) As Long
Private Declare Function AbortPrinter Lib "winspool.drv" (ByVal _
    hPrinter As Long) As Long

Private Sub Command1_Click()
    Dim lhPrinter As Long
    Dim lReturn As Long
    Dim lpcWritten As Long
    Dim lDoc As Long
    Dim sWrittenData As String
    Dim MyDocInfo As DOCINFO
    Dim intBarcode As String
    intBarcode = "12345"
    lReturn = OpenPrinter(Printer.DeviceName, lhPrinter, 0)  ' \\\Argox

    If lReturn = 0 Then
        MsgBox "The Printer Name 

Open in new window

New feature and membership benefit!
LVL 10
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.


Two Computer with each program with textbox

I have project with Textbox and Button

Also have project with textbox only

How can I send the text in the textbox from PC1 to PC2?

Any help please, Thanks
How can I connect SQL to my Form (datagridview1)

I am new here in I don't have any idea but I am willing to learn, I do coding in VB but not using SQL and I only use text file for my database (txt, dll, bat)

this is my prev. project here and they helped me a lot, now I am trying to connect SQL, please help and TIA

Listview and Datagridview answered question here in Expert Exchange - this is my prev post


SQL Connection
:IP Address
SQLMy Table
Hi Experts,

I have a code that should be changing the SQL of a pass-through query, and I realized suddenly that each time the code executes, new tables are being created in my app..

See attached.

Below is the code.

Private Sub ComboFindByRef_Change()
    Dim qd As QueryDef, s As String
    On Error Resume Next
    If Me.ActiveControl.Name = "ComboFindByRef" Then
        s = ComboFindByRef.Text
        s = ComboFindByRef.Column(1)
    End If
    Set qd = CurrentDb.QueryDefs("EmployeesSearchPTQry")
    'qd.sql = "select * from [dbo].[EmployeestblSelectBy" & "Ref" & "PH] ('" & Me.ComboFindByRef.Text & "','" & Nz(ComboFindByRefField, "ContactPerson") & "')"
    qd.sql = "exec [dbo].[PH_EmployeestblSelectByRef] '" & s & "','" & Nz(ComboFindByRefField, "ContactPerson") & "'"
   qd.Connect = "ODBC;driver={SQL Server};server=...;"

    Me.ComboFindByRef.RowSource = "EmployeesSearchPTQry"
    SendKeys "{F4}"
End Sub

Open in new window

Any idea whats going on??!

Thanks in advance

I need your help on a macro.

I have an MSHFlexgrid1 that i need to populate based on 3 different criteria.

No1: Start date
No2 How many Weeks
No3: Days requested

Let's take below picture as an example:
I have the start date of : 28-08-2017
I also have the number of week set to 10
And i also have the "Tuesday" day checked
What i would expect to see in the MSHFlexgrid1 is to add 10 rows where i would see the following 10 Tuesday dates starting on the Starting date of 28-08-2017 .

That would be:

I could check multiple different days also. Based on the days i check, it would add the the dates in the MSHFlexgrid1 in to LaneStartDateTime column.

How can i do that?

Thank you for your help.
This is the code, how to convert this? Thank you

private void button1_Click(object sender, EventArgs e)
/* Clear the list view items */

// Stream on to the textfile
var sr = new StreamReader("data.txt");

//create an object list type of string to store your data later
List<string> l = new List<string>();

//variable to hold the data from the textfile
string data = "";

//loop through the data line by line
while ((data = sr.ReadLine()) != null)
// since it is comma separated split it with comma and check if it is equal to your textbox value
if (data.Split(',')[2].Trim().Equals(textBox1.Text))
// if found store the data to list 



//unique id
// break the loop since you found it already no need for the loop to continue
//dont forget to close the streamreader

//create a listview item object and pass the data to the list view
var item = new ListViewItem(l.ElementAt(0));


Open in new window

Hi experts, I'm having difficulties in connecting database with sql 8 to a network or other pc. Codes below is working locally but when i try to run it via network an error occur,  says; " Server does not exist" . Im using OS Widows 10. Thanks!

Sub eMiles(edate, db As String, rmrk As String)
        Dim e As Save_Files
        Set e = New Save_Files
        e.OPEN_CON db, "SkyJob" & "\SQLEXPRESS"
            e.RecordHistory edate, rmrk
end sub

Open in new window

Public Sub OPEN_CON(db As String, ServerName As String)
Set cn = New ADODB.Connection
cn.Provider = "sqloledb"
cn.ConnectionTimeout = 12
cn.Properties("Data source").Value = Trim(ServerName)
cn.Properties("Initial Catalog").Value = Trim(db)
cn.Properties("User ID").Value = "sa"
cn.Properties("Password").Value = "100"
cn.CursorLocation = adUseClient
cn.Open , "sa", ""

If Err.Number <> 0 Then
    MsgBox (Err.Number & "|" & Err.Description)
End If

End Sub

Open in new window


I would like to be able to divide a cost per any amount so that the total once divided equals the cost not divided.

If the Cost = 357.25$
If the divided value = 3
If we do 357.25 / 3 = 119.083333333333

So i cannot say that the value would be 119.08 per value cause 119.08*3 = 357.24.
So it would have to put 119.09 on the first and 119.08 on the 2 last value for a total of 357.25.

How can i do that?

Before the division:
Thanks for your help
Hello guys,

I need help with the creation of a Macro that is doing my head...

Let me try to resume so it is super clear for everyone :

SHEET 1 = A simple food plan with Name / client Code / Menu Type and Allergies (then food below). This sheet is a individual and set by client.

SHEET 2 = An order form with the list of clients (order form contains names / client code / Menu type and allergies). This sheet is a whole list of client.

WHAT I WANT = A Macro that would generate the following report

- The macro would open Sheet 3 - Copy the whole format from sheet 1 - paste it in sheet 3 - goes to sheet 2 and copy the data (into the form pasted in sheet 3 from sheet 1) with the following information -> SHEET 2 -> Copy C6 paste it in SHEET 3 cell D4. / SHEET 2 -> Copy F6 and paste it in SHEET cell A1 / SHEET 2 Copy B6 and paste in SHEET 3 cell D5 / SHEET 2 copy K6 and paste in SHEET 3 cell B1.

- When this is done it would rename SHEET 3 with the code present in SHEET 3 Cell B1.


- THe macro would finally repeat as many new sheet with the above process as there are clients listed in SHEET 2 (if there is 5 clients - 5 new sheets would be created, if 20 clients then 20 new sheets). Finally each new sheet would be renamed as per cell B1 in that new sheet.

Thanks a lot guys that would help A LOT.
I have a script that will create folders for students with individual data folders contained therein.  For example, when I run the script for folder 2025 it will create sub folders labeled for each user (IE: “Lskywalker”, “Hsolo”, etc.)  Users have access to their folder to save data.

The problem I am facing is when I run my script to create all the new users folders it gives the student user “Full” rights to the folder, which we don’t want them to have; just “Read / Write” (to prevent them from changing permissions, etc).  I can make the change on each folder manually but that is extremely time consuming. I’ve found that I can use the “cacls” command to change the permissions, but not sure how to combine this into my current script.

Any help would be greatly appreciated.
Concerto Cloud for Software Providers & ISVs
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Been using GPO preferences for shortcuts and they are working well...except for one I need to open a UNC path

Windows 2008r2 domain
Windows 10 laptops

Here's the preference setup
Hello friends I have a problem with DIGITALPERSONA ONE TOUCH READER BIOMETRIC ,I cant take and save image of finger to jpg,here is a example of my code.....

Private Sub DPFPEnrollmentControl1_OnComplete(ByVal pSerialNumber As String, ByVal lEnrolledFinger As Long)
Dim oPicture As IPictureDisp
Set oPicture = DPFPEnrollmentControl1.EnrolledFingersMask
Picture1.Picture = DPFPVerificationControl1
End Sub

really I dont know how to resoved it if anyone can help me would be a GREAT help......thank you for you time.
Folks I keep getting an error on this code at:
.lstCategory.ListIndex = 0

Open in new window

in the below subroutine when the workbook opens and I haven't figured out what is causing it?
Private Sub Workbook_Open()
Dim intIndex As Integer

With Worksheets("Main Menu")
    For intIndex = 10 To .UsedRange.Rows.Count
        .Cells(intIndex, 1).Value = ""
        .lstCategory.ListIndex = 0
End With

Open in new window

Error opening workbook
Hi experts, I have a problem obtaining data in sqlserver in which in my sql command I need to advance 1 day of my time end before able to obtain the data.  My data field in sql is look like this, "2017-08-17 10:00:00.000"  this means that it has a time and this is August 17, 2017. In my sql command I cannot obtain this record if i set the time end to "08/17/2017" but  "08/18/2017" meaning i need to advance 1 day. Is there anyone who can explain me why. What shall i do to make my sql command set "08/17/2017"?

Set rs = cn.Execute("Select Proname, TheDate,  from sTable where TheDate Between '" & "08/17/2017" & "' And '" & "08/17/2017") & ") 

Open in new window

Hi All,


According to my work, pdf files will be get merged in a specific path. I need to give dynamic file names to the mergedOutPut File.
1. Is there any way to pass parameters to the file name?
2.Or I can give fixed file name to the mergedOutput file through my code.After that Can I  rename it into dynamic naming conversion?

I saw RENAME command in Foxpro. But I am not sure whether I can pass parameters to it

Any help regarding this would be highly appreciated.

Thanks in Advance.
I'm working on a macro that inserts a style separator before the first period in every heading level 2 paragraph. It is also set up to skip any paragraph that is not heading 2. Currently it only works as many times as you specifically trigger it, but I would like it to continue looping until the last style separator is inserted in the last heading 2 paragraph. I can't figure out how to loop this without creating an infinite loop. I'm new to the macro writing game so please excuse my code:

 If Selection.Style = "Heading 2" Then
            Selection.MoveUntil Cset:=".", Count:=100
            Application.Run MacroName:="LWmacros.basHNum.InsertStyleSeparator"
            ActiveWindow.Selection.GoTo wdGoToHeading, wdGoToNext

ElseIf Selection.Style <> "Heading 2" Then
             ActiveWindow.Selection.GoTo wdGoToHeading, wdGoToNext

End If 

Open in new window

 I'm not sure what sort of condition I would need to set for the Do Loop for it to end after the last heading level 2 paragraph is found.

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.