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

x

Visual Basic Classic

164K

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 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.

 
 screengrab2.png

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")
    Else
        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"))
      rs.MoveNext
    Loop
    rs.Close
    
    'debug
    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

0
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.

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
Thanks
0
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

Adrienne
0
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?
0
Hi

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.
VB6-Copy-Paste.zip
0
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]
0
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
0
Hello experts,

I have the following procedure in order to reset & delete the various guides.
Sub DeleteGuides()
    With ActivePresentation.Guides
        ' Delete the second guide
        .Item(2).Delete
    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.
0
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.

Thanks
0
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,
Regards
_07_VB6-send_mail.rar
0
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!

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?
0
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.
Thanks
0
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")
objMSWord.Quit

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
Word?
[embed=doc 1403738]
0
I need a copy of msflxgrd.ocx verion 6.1.98.6.   I have msflxgrd.ocx version 6.1.97.82 but my Security Vulnerability Check states that I need version 6.1.98.6.
This is a 32 bit version.

The required MS updates state that I need VB 6.0 installed.
0
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

Sincerely
0
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")
    Else
       nPrompt = MsgBox("Please input the specific month!", vbExclamation)
    …
0
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
Next

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

Open in new window

0
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.
C--Users-lfreund-Documents-EE---COL.xlsx
0
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.
0
10 Tips to Protect Your Business from Ransomware
LVL 1
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

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
0
Is it possible to create a cross-platform desktop application in Visual Studio 2017 that will run in both Windows 10 and Linux environments (how is it done)?  
I don't see any "New Project" options that stand out, nor much information on the web.

Thanks
1
Hello Experts,

I am looking for a procedure which cover the following requirement:
-Loop into the various worksheets of open workbook
-Check in range A1 (which is the result of a merge between a1 till c3) that value begins with specific string such as "string":
-If there is no worksheet which this requirement display a message "ko no sheet with the required string" and exit sub
-If there is more than one worksheet which meets the string requirement "ko there are more than one sheets with the required sting" and exit sub
-If there is one worksheet with the required string display a message "ok the procedure can be run" and select/activate the worksheet which meet the requirement.

I attached dummy file.

If you have questions, please contact me.

Thank you very much for your help.
Check-Range-Value.xlsm
0
Hi Experts,
I have the following code reading a CSV file line by line, parsing the columns and executing some commands...
Do While Not EOF(1)
                Line Input #1, lineOfFile
                columns = SplitRe(lineOfFile, ",(?=(?:[^""]*""[^""]*"")*(?![^""]*""))")
                pk = columns(iPKColumnNum)...
Loop

Public Function SplitRe(Text As String, Pattern As String, Optional IgnoreCase As Boolean) As String()
    Static re As Object

    If re Is Nothing Then
        Set re = CreateObject("VBScript.RegExp")
        re.Global = True
        re.MultiLine = True
    End If

    re.IgnoreCase = IgnoreCase
    re.Pattern = Pattern
    SplitRe = Strings.Split(re.Replace(Text, ChrW(-1)), ChrW(-1))
End Function

Open in new window

Now I realized that some times there are 2 carriage return characters between the lines and this causes the code above to render an error, see attached.
How do I handle this?
Untitled.png
0
I have a folder which has multiple other sub folders inside it and in each of those sub folders there are different files and only one htm file.

the htm file contains table and text.

Currently, i am manually opening these hundreds of htm files and searching the words and then i put them manually in an excel file

Please see attached example file of Excel .



Product231
Product575
Product7867
Plastic
Rubber
Iron
PVC
Pipe
Liquid
Shell
Stone
Brick
Book2.xlsm
0
I converted a vb6 function to .NET. My Boss says it "isn't very .NET". First is the vb6 function, then my conversion. Can anyone suggest ways to make it "more .NET?"

Public Function CalculateCheckDigit(sInString As String) As Integer
' Starter requires a check digit on the end of the Serial Ship Code
' for their Optional ASN label

' Algorithm is as follows:
' Strip out the spaces and punction from the incoming string
' (e.g. take only the stuff that is numeric)
' Add all of the odd positions together (OddSum)
' Add all of the even positions together (EvenSum)
' Multiply OddSum by 3 to get Result C
' Add Result C + EvenSum, divide by 10 and get the remainder
' 10 - Remainder = Final Check digit

    Dim sChar As String
    Dim sStrippedString As String
    Dim I As Integer
    Dim iOddSum As Integer
    Dim iEvenSum As Integer
    Dim iResultC As Integer
    Dim iRemainder As Integer

    On Error GoTo Error_H

    For I = 1 To Len(sInString)
        sChar = Mid$(sInString, I, 1)
        If IsNumeric(sChar) Then
            sStrippedString = sStrippedString & sChar
        End If
    Next I
   
    For I = 1 To Len(sStrippedString)
        sChar = Mid$(sStrippedString, I, 1)
        If I Mod 2 = 0 Then  ' Even position in the string
            iEvenSum = iEvenSum + Val(sChar)
        Else
            iOddSum = iOddSum + Val(sChar)
        End If
    Next I
    iResultC = iOddSum * 3
    iRemainder = (iResultC + iEvenSum) Mod 10
   …
0

Visual Basic Classic

164K

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.