Visual Basic Classic

163K

Solutions

58K

Contributors

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 had to change the computer I use for my vb6 programming.  When I try to re-compile a module I get a Break compatibility warning.

Old Computer:  Win 10
New Computer: Win 7

Below is the reason for the compatibility issue:

Original Definition:
Property Set to Connection(RHS As ADODB.Connection_Deprecated)

Current Definition:
Property Set Connection(RHS As ADODB.Connection)

Question:
Where does Set Connection(RHS As ADODB.Connection) come from and how do I set it to Connection(RHS As ADODB.Connection_Deprecated)
0
Instantly Create Instructional Tutorials
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Hi Everyone,
 
I am using one VBS which delete and Insert records from Excel. But need some adjustments here.
For example this script deleting 10 records and inserting 10 records into Excel, but replicating some records again at right side again and again after each run.
And my Excel has 3 multiple Sheet, but I need to insert into a particular sheet i.e. Sheet2
 
after execution I am seeing these defects
1. Legends moved to somewhere else,
2. row 1-6 repeated but right side.
 
Here is my CSV data.
But after second run data got inserts some other place.
 
Name,Location,Phone,Comment1,Comment2,comment3
"ABC","Pune",123,"Expert Value","! Easy","Popular"
"XYZ","Kol",567,"! Expert value",Easy,"!Credit"
"PQR","Mum",234,"NOT value","Value for money","Debit"
"RST","DEL",0,"Value","NO value","N/A"
"Ram","KOL",100,"NO Value","value","N/A"
"XYZ","Kol",567,"! Expert value","!Easy","!Credit"
"qwer","DEL",567,"Expert value","Easy","!Credit"
"cvbn","Pune",567,"! Expert value","!Easy","!Debit"
"rtyu","DEL",567,"! Expert value","Easy","!Credit"
"kllo","Pune",567,"Expert value","NOT Easy","!Bad"

Open in new window


Here is my existing VBS.
 
srccsvfile = Wscript.Arguments(0)
tgtxlsfile = Wscript.Arguments(1)
 
'Create Spreadsheet
'Look for an existing Excel instance.
On Error Resume Next ' Turn on the error handling flag
Set objExcel = GetObject(, "Excel.Application")
'If not found, create a new instance.
If Err.Number = 429 Then  '> 0
  Set objExcel = 

Open in new window

0
Hi ... I want to correctly add the minutes and show them in list1 every 45 minutes, I have two text boxes representing hour and minutes and a textbox that represents the minutes to show, how can I do?

Dim Cada
Dim icountHora
Dim icountMin
Dim i
List1.Clear
Cada = tturnomañanacada.Text
Dim t7
Dim t23
t7 = Comboturnomañanade.Text
t23 = Comboturnomañanahasta.Text
          For icountHora = t7 To t23 - 1
             For icountMin = 0 To 50 Step Cada
     

        List1.AddItem Format(icountHora & ":" & icountMin, "hh:mm")
         Next icountMin
       Next icountHora
0
VB6: I have two arrays of 8 text boxes each. The first is populated with texts. The second is all empty. I want to transfer the text from each of the first array to a different Indexed text box in the second array. (It saves a lot of typing, and possible typos.)

I tried a “drag and drop” using “mouse up” and “mouse down” events. Can’t seem to get it to work.

Dim sText as string

Source text box MouseDown event:
sText = txtBoxA(Index).text

Destination text box MouseUp event:
txtBoxB(Index).text = sText

What’s the secret here that I am missing?

Right now I am doing this using the click events. That requires the user to click, move the mouse, and click again. Drag and drop would be smoother.
0
Hello Experts,

I inherited an ASP application, that is very messy, across multiple of domains, virtual directories, etc... I'm not even able to create a test environment, so I'm making all changes live.

Anyways, here's the situation...

On MSSQL i have a fldEnabled bit set to False

In one common.asp include, I have
Session("bolNightSeason")   = (.Fields("fldEnabled"))

Open in new window


I also tried
Session("bolNightSeason")   = CBool(.Fields("fldEnabled"))

Open in new window


Then, after including common.asp in another file,, I have
bolNightSeason = Session("bolNightSeason")
Response.Write("night = " & bolNightSeason)

Open in new window


Now the issue is in the output...

  • When I first start the browser, I see
  • night=
  • ...
  • expected as i set it to False

  • Then, if i hit Refresh I see
  • night=True
  • ...
  • How is this possible, when the field value in the db is still set it to False?

  • Refreshing remains True, but closing and re-opening the browser goes  back to ""

Can any one spot why the value is changing, or advise on how I can trace the issue?

Any help will be greatly appreciated.

Thank you.
0
Hello

I am looking for help to write some code so that I have a listbox (or similar) that can enter a date into a cell.

Unfortunately my work IT department have blocked 6.0 objects, so can't use any of the pop-up calendars available, therefore, I would like a userform with 3 entry points; day number, month and year, to be selected (via dropdown or similar) and then entered into the cell in the format DD/MM/YY.

It's Friday and I'm full of cold and my brain can't take attempting the different answers that come up in google...please can someone help me!!!!!

Thanks
Amy
0
I need help with a Word Macro which will search for the word "apple" in a word document and change the font color of all the instances of the word ("apple") to green.
Thank you for your help.
0
Hi Guys, I have a Macro called PL Star Summary on the "Control" tab which uses a Worksheet Function which adds up data in a Tab of the attachment called "PL Star IMM_FX_Trading" by Portfolio name and populates a summary of the data. 3 Portfolios called FX_FLOWS_PR, PB_FX_PR & RETAIL_FX_PR should be WORKSHEETFUNCTION(SUM * -1) so an IF statement needs  to be inserted into the code whereas all the other Portfolios will remain SUM* 1. The subprocedure is called "CalculateNumbers" and looks like this:

Sub CalculateNumbers(ByVal strSheetName As String)
    Dim intTyplogolyCol As Integer
    Dim intPFCol As Integer
    Dim intPLCol As Integer
    Dim strPLColName As String
    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
    Dim intHeaderPFCol As Integer
    Dim intHeaderPLCol As Integer
    Dim strHeaderPFName As String
    Dim strHeaderTypologyName As String
    Dim rRange As Range
    Dim dblPL As Double
    Dim strRange As String
    
    Sheets(strSheetName).Select
      ActiveSheet.AutoFilterMode = False
    If strSheetName = "PL Star MTM" Then
        intTyplogolyCol = 7
        intPFCol = 4
    End If
    If strSheetName = "PL Star IMM_FX_Trading" Then
        intTyplogolyCol = 7
        intPFCol = 4
    End If
    
    If strSheetName = "PL Star Accrual" Then
        intTyplogolyCol = 7
        intPFCol = 4
    End If
    
     If strSheetName = "PL Star MTM Accrual" Then
        intTyplogolyCol = 7
        intPFCol = 4
    End If
    
    'Get PF & 

Open in new window

0
I am making slow progress with my treeview. The latest problem is the first child node repeating until Access give an error 3014 'Can't Open Any More Tables'


Capture-6.PNG
What am I doing wrong?

Private Sub addChildren(tv As TreeView, nodParent As node, rsReqs As DAO.Recordset, lngParentID As Long)
   Dim strFind As String
   
   Dim strSQL2 As String

  Set rsReqs = CurrentDb.OpenRecordset("Query2")
   
   
   strFind = "HeaderID=" & lngParentID
   rsReqs.FindFirst strFind
   Dim nodX As node
   Dim strBook As String
   rsReqs.MoveFirst
    Do While Not rsReqs.NoMatch
      Set nodX = tv.Nodes.Add(nodParent, tvwChild, , Left(rsReqs!StockCode, 50))
      strBook = rsReqs.Bookmark
      addChildren tv, nodX, rsReqs, rsReqs!HeaderID
      rsReqs.Bookmark = strBook
      rsReqs.FindNext strFind
   Loop
   
   
   
   
End Sub

Open in new window

0
I need to archive each mail via specific account each time its received or send. For received mail i use this script:

Public Sub SaveMsgInbox(Item As Outlook.MailItem)
  Dim sPath As String
  Dim dtDate As Date
  Dim sName As String
  Dim enviro As String
 
  enviro = CStr(Environ("USERPROFILE"))
   
  sName = Item.Subject
  ReplaceCharsForFileName sName, "_"
 
  dtDate = Item.ReceivedTime
  sName = sName & ".msg"

   sPath = "Y:\mail_arhiva\msg_arhiva\Inbox\"
  Debug.Print sPath & sName
  Item.SaveAs sPath & sName, olMSG
End Sub
 
Private Sub ReplaceCharsForFileName(sName As String, _
  sChr As String _
)
  sName = Replace(sName, "/", sChr)
  sName = Replace(sName, "\", sChr)
  sName = Replace(sName, ":", sChr)
  sName = Replace(sName, "?", sChr)
  sName = Replace(sName, Chr(34), sChr)
  sName = Replace(sName, "<", sChr)
  sName = Replace(sName, ">", sChr)
  sName = Replace(sName, "|", sChr)
End Sub

Open in new window


However, I cant make outlook 2010 run a script when i send mail. Otherwise i would use same script just different save path.

Edit: Code put into a snippet box. Graham Skan
0
Free Tool: Port Scanner
LVL 9
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

I have an Access 2010 form (frmContributionSingleRec) that is working correctly except for two things.  When the Move Record button is clicked the record displayed on the form moves to another table as expected but then a dialogue box opens which prompts me to enter a parameter value for another form.  That other form is not open and there is no code behind the open form that makes reference to it.  The same thing happens when another button is clicked that is supposed to confirm the record has been moved.  None of the queries that run using code behind the form reference the closed form.

Something is obviously referencing the closed form but after reviewing everything connected to the open form I'm stumped. The code behind the Move Record button is shown below.

Private Sub cmdMoveRecord_Click()
    Dim strMsg As String
   
    strMsg = IIf(IsNull([Org or Project Name]), "    Organization Name" & vbCrLf, Null) & _
             IIf(IsNull([Street Address]), "    Address" & vbCrLf, Null) & _
             IIf(IsNull([City]), "    City" & vbCrLf, Null) & _
             IIf(IsNull([County]), "    County" & vbCrLf, Null) & _
             IIf(IsNull([State]), "    State" & vbCrLf, Null) & _
             IIf(IsNull([Sub Category]), "    Sub Category" & vbCrLf, Null) & _
             IIf(IsNull([Zip Code]), "    Zip Code" & vbCrLf, Null) & _
             IIf(IsNull([Loan Number]), "    Loan Number" & vbCrLf, Null) & _
             IIf(IsNull([Dollar Amount]), "    …
0
When opening Word Document files  recently  a window comes up with a title Microsoft Visual Basic, with an option to 'end' or 'debug'. What is this about? Can this be got rid of?
0
Hello.

I have a VB application that calls an external dll for address verification.  I need to add this code to a C# application but my conversion of the code is not being accepted.

VB6 code:

Declare Function UNZ_INIT_EX Lib "UNZDLL32.DLL" () As Long
Declare Function UNZ_TERM Lib "UNZDLL32.DLL" (ByVal hUnz As Long) As Long
Declare Function UNZ_CHECKADDRESS Lib "UNZDLL32.DLL" (ByVal hUnz As Long, ByVal Line1$, ByVal line2$, ByVal line3$, ByVal Line4$) As Long
Declare Sub UNZ_GETSTDADDRESS Lib "UNZDLL32.DLL" (ByVal hUnz As Long, ByVal szFirmName As String, ByVal szPRUrb As String, ByVal szDelLine As String, ByVal szLastLine As String)
Declare Sub UNZ_GETERRORTEXT Lib "UNZDLL32.DLL" (ByVal hUnz As Long, ByVal ErrorText As String)
Declare Function UNZ_GETMATCHCOUNT Lib "UNZDLL32.DLL" (ByVal hUnz As Long) As Long
Declare Sub UNZ_GETMATCHADDR Lib "UNZDLL32.DLL" (ByVal hUnz As Long, ByVal intItem As Integer, ByVal szFirmName As String, ByVal szPRUrb As String, ByVal szDelLine As String, ByVal szLastLine As String)
Declare Sub UNZ_GETAREACODE Lib "UNZDLL32.DLL" (ByVal hUnz As Long, ByVal szAreaCode As String)

C# code:

using System.Runtime.InteropServices;
[DllImport("unzdll32.dll", CharSet.Auto)]

And I started doing this:

public static extern long UNZ_INIT_EX();
public static extern long UNZ_TERM(long hUnz);

But, VS2017 doesn't like it.

Thoughts?  Thanks. :)
0
I'm working on an old vb6 windows forms application.

On a window I notice it has a grid.

When I select the grid and look at the properties of the grid, it shows that its a vaSpread control.

Anyone know the url for the API reference for vaSpread or what type of control is vaSpread?
0
bjr.  je suis étudiante et ma thèse de soutenance porte sur SDWAN, SDN, NFV ,VNF.  besoin d'aide ou des sites qui pourront m'aider
0
I'm trying to rebuild a development environment which crashed.  I'm using VB6 on a virtual XP machine (please don't laugh!).  I've got everything back together - no errors when loading the project. When I run the project it opens a connection to the SQL server, but when it sets up to read the first table, I get an error "Method or data member not found".
Set rsSayings = New ADODB.Recordset
With rsSayings
       .CursorType = adOpenStatic        The error is on "CursorType"
       .
       . 
       .
End With

Open in new window

Now please don't go into why this code is bad, and ADODB shouldn't be used.  The code isn't the problem - I think I'm missing a reference, but I can't find which one is missing.  I have included all the references that I can think of -
Microsoft DAO 3.6 Object Lib
Microsoft Data Enfiroment
Microsoft ADO Ext. 2.8...
Mictosoft Data Access Components
Microsoft SQLDMO Object Lib.

I appreciate any help
Thanks.
0
I have two macro that I created that I would like to combine them into one Macro using a command button in Excel from the Mod Cost Calculator tab in Excel.  The first macro comes from the Excel Tab titled, "Database Tab", and the second Macro reference excel tab Data position Tab.  Please help me!
Sub ADOFromExYoucelToAccess()
' exports data from the active worksheet to a table in an Access database
' this procedure must be edited before use
Dim cn As ADODB.Connection, rs As ADODB.Recordset, R As Long
' connect to the Access database
Set cn = New ADODB.Connection
cn.Open "provider = Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=R:\Modular Cost Tables\FY 2018A\RCA Database Prep\Terry's Updates\FY 2018 AOP RCA Database_062717_SCOPS Locations.accdb;"
 ' open a recordset
Set rs = New ADODB.Recordset
rs.Open "[FY18 Fee Review Mod Cost Table Data]", cn, adOpenKeyset, adLockOptimistic, adCmdTable
' all records in a table
R = 2 ' the start row in the worksheet
Do While Len(Range("A" & R).Value) > 0
    ' repeat until first empty cell in column A
    With rs
        .AddNew ' create a new record
        ' add values to each field in the record
        .Fields("Project_ID") = Range("A" & R).Value
        .Fields("Item") = Range("B" & R).Text
        .Fields("Object_Class") = Range("C" & R).Text
        .Fields("OC_Name") = Range("D" & R).Text
        .Fields("ProjectTask") = Range("E" & R).Text
        .Fields("Fund") = Range("F" & R).Text
        .Fields("Prog") = Range("G" & 

Open in new window

0
Hi experts, Is it possible to get the sum of a certain fields during Insert execution? Please see my code below where I tried to get the sum of a credit but the codes is not working. Any help please!

Public Sub SaveSalesPOS(rct, record, disc, tot, edate, cid, credit, check, cuscode)
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

        cn.Execute ("Insert into CustomersLedger(CustomersCode,iDate,TransactionNumber,Credit,Debit,Balance) Values('" & cuscode & "','" & _
                    edate & "','" & record & "'," & credit & "," & "0" & "," & Sum(SalesPerTrx.credit) & " where CustomersCode='" & cuscode & "')")
        
Set rs = Nothing
End Sub

Open in new window

0
The error is component dbgrid32.ocx or one of its components is not registered correctly.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE
LVL 4
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Hi there all..

I've three RichTextBox . I can save the three RichTextBox texts into one RTF file.

How can i read back from this file to the three  RichTextBoxs ?

THANKS...
0
Hi All,

Can any one help me in building a code to login https://leadferret.com/login using either WinHTTP or msxml2.xmlhttp request? Using IE Automation I got success but its very slow.

Purpose: Pull information from a web page. (Specifically Email ID here)
Issue: Without login it gives me partial information while gives rest of the information on a web page post login.

Demo Url: https://leadferret.com/directory/person/kristen-knapper/217985

Regards,
Niraj Patel.
0
Hi, I am new to this place. I want to know about internals of vb6. I would like to know the memory layout of a vb6 control like a command button or UserControl etc. How data fields are stored, and how system access those while running the vb6 application.
0
I would like to set the From background colour into two equal halves,the upper one is black ,the second bottom half into blue.
0
Is there any way to have a vb6 child form show a new control array item without reloading the page?  Reloadng the page resets one variable that I would like to not be re-set.  I assume there is no way to do something like  you can in classic asp via passing a query string?
0
I created a function that will query a SQL Server 2000 database and return a value based on the contents of cell A1.  I "call" this function from cell B1.

If I copy B1 down to B2 (using A2 as the "filter") the recordset gets completely re-queried from the database.

Can I avoid this?  I'd like B2, C2, etc just to pull/filter data from a disconnected or memory resident recordset.

Thanks
0

Visual Basic Classic

163K

Solutions

58K

Contributors

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.