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 have traced an issue with syntax on line 1.  Sometimes the code works and sometimes it does not based on how I type the date 7/1/2017.  What is the correct way to do the syntax

    If DTPicker1.Value < "7/01/2017" Or DTPicker1.Value > MaximumDate Then
        MsgBox "The DATE you entered is Not Authorized.  Please Re-Enter a Valid Date.  Date will be reset.", vbOKOnly, "Invalid Date"
        DTPicker1 = ServerTime
        Text2.SetFocus
    End If

Open in new window

0
[Webinar] Database Backup and Recovery
LVL 11
[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

I have a shortcut menu for some reports so that the user can run a function to change the Report Settings (Fonts and sizes, etc.)   The reports are opened in Print Preview and the user right clicks on the report to get the shortcut menu.

 It has worked well for the past few years.  Now, it works on some reports but not others.  All other functions on the shortcut menu work as they should.  I have not touched this code since I wrote it.  I have attached a text file containing the code that creates the menu.

Can anyone suggest why this may be?

This problem is critical as it is delaying the release of an update to my product.

Thanks in advance.

CRB

Shortcut-Menu-code.txt
0
Hi All,

I am trying to create a message box in vbscript. I need to put a warning sign, but it only appears on the top. Could someone please help?

Here is the code.

intAnswer = _
    Msgbox("This is a Test." & vbCrLf & vbCrLf & "Testing will begin in 1 minute." & vbCrLf & vbCrLf & " I need warning sign at this line before the text. " & vbCrLf & vbCrLf & "Select Yes to Start or No to Exit.", _
        vbYesNo + VbExclamation, "Help Me")

Thanks
Vicki
0
I find myself maintaining two rather large legacy programs that I wrote years ago under XP in VB6. Two sporting clubs depend on it. I’ve repeatedly advised them to find somebody fluent in modern computer languages to re-write these things. I’m 84 going on 85, and simply don’t have the ambition.

Question: I’ve been advised that the VB6 development suite will not run on Win 7, and newer OS’s. I’m curious. Why exactly is that the case?
0
I just started using VBA and need some guidance.
Aim: Highlight cells upon this 4 conditions. All conditions have to be applied

1.Same Date
2.Same Name
3.Diff Address
4.Overlapping timing
    example:
   data 1> start time: 09:00 end time: 09:35
   data 2> start time: 09:20 end time: 10:00
   When the start time of the second data overlaps with the end time of the first data, it should be highlighted

Sample data:

sample data
Sample Output:

Sample output
What I have done:

Sub DupEntry()
Dim cel As Variant
Dim rng As Range
Dim clr As Long
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set rng = Range("A1:A" & Range("A1048576").End(xlUp).Row)
rng.Interior.ColorIndex = xlNone
clr = 3
For Each cel In rng
If Application.WorksheetFunction.CountIf(rng, cel) > 1 Then
If WorksheetFunction.CountIf(Range("A1:A" & cel.Row), cel) = 1 Then
cel.Interior.ColorIndex = clr
clr = clr + 1
Else
cel.Interior.ColorIndex = rng.Cells(WorksheetFunction.Match(cel.Value, rng, False), 1).Interior.ColorIndex
End If
End If
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
excel vba excel-vba

Open in new window


It only highlights the duplicate in the first column

Any help would be appreciated. Thank you!
0
I want to check user provided MS word file is empty or not from excel macro.
Although i test as following example, its not work.
 Word VBA: How do I determine if the current Word document is ...
0
How do I create a progress bar that has a range of 0 to 1020 seconds will advance every 1 second?  I know I have to use a timer control.  I’m not sure about the values for the two controls.

Thanks
0
Maintaining a legacy application written in VB6.

Several files are read in, modified, and written out. It is advisable for the user to preserve the original files, “just in case”. Currently, the user is required to manually copy each “Name.txt” to “Name_bak.txt”. Then, when the application is run, Name_bak.txt is read in, and the modified file is written out as Name.txt.

It would be convenient to automate this. I could read Name.txt in, immediately write it out as Name_bak.txt, then proceed with the modifications, creating a new Name.txt.

Question: Is there a way in VB6 to do this file archiving (renaming) directly? Some of the files are excel spreadsheets, and they are complicated to read in and write out, cell by cell.
0
What is the best way to write all selected items in a list box to an array.  Here is what I have:

        
    'get races to assign to
    k = 0
    ReDim RacesToAssign(0)
    For i = 0 To lstRaces.ListCount - 1
        If lstRaces.Selected(i) = True Then
                    RacesToAssign(k) = lstRaces.Text
                    k = k + 1
                    ReDim Preserve RacesToAssign(k)
        End If
    Next i

Open in new window

0
Hello community, I have a pretty tight deadline on this in the next few days, but need your expert help.

I am trying to create a mail merge to send out to a group of over 500 recipients.

Unfortunately the data is not in an access database or anything else that is useful to me, it is in excel files.

Secondly, the excel data is structured with headings and as follows.

Fname, Lname, UserAccount1, TypeA, InvestmentAmount, Date, TypeOfInvestment, city, state, address1, address2, zip, etc.
Fname, Lname, UserAccount1, TypeB, InvestomentAmount, Date, TypeOfInvestment, city, state, address1, address2, zip, etc.
Fname, Lname, UserAccount1, TypeC, InvestmentAmount, Date, TypeOfInvestment, city, state, address1, address2, zip, etc.
Fname, Lname, UserAccount2, TypeA, InvestmentAmount, Date, TypeOfInvestment, city, state, address1, address2, zip, etc.
Fname, Lname, UserAccount2, TypeC, InvestmentAmount, Date, TypeOfInvestment, city, state, address1, address2, zip, etc.
Fname, Lname, UserAccount3, TypeC, InvestmentAmount, Date, TypeOfInvestment, city, state, address1, address2, zip, etc.
Fname, Lname, UserAccount3, TypeD, InvestmentAmount, Date, TypeOfInvestment, city, state, address1, address2, zip, etc.
Fname, Lname, Capture.JPGUserAccount3, TypeE, InvestmentAmount, Date, TypeOfInvestment, city, state, address1, address2, zip, etc.

I need to setup a mail merge that will group the following data into a single page mailing to each "account or user".

For …
0
Industry Leaders: We Want Your Opinion!
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Can anyone think of a good reason to declare variables as objects instead of the appropriate variable type in VB6?

I'm experimenting with converting a VB6 app to .NET (2008 for now, then, if it works, 2017) and looking over the code, the original dev declared everything as objects.  Dim intLoop1 As Object (why not integer?)  Is there (could there be) a good reason for this or was he being lazy as my gut tells me?)

Thanks!
0
What is the proper way to create an md 5 hash tag
    Dim TerminalID As String = "33001"
    Dim OrderID As String = "12345"
    Dim Amount As String = "1.00"
    Dim Date_Time As String = System.DateTime.Now.ToString("dd-MM-yyyy:HH:mm:ss:fff", CultureInfo.InvariantCulture)
    Dim SecretKey As String = "SandboxSecret001"

Hash tag on the following combined strings.
TerminalID & OrderID & Amount & Date_Time & SecretKey
0
My first project is to create a button that will mimic the MS Excel find and find next function in a workbook.  I have created a button in my column labels row that will follow the user as they scroll down the page.  I tried to start the code with a macro to search, but it comes up blank.

Can you help me?  (I thought this would be much easier to begin with, NOT!)
Thanks,
Kim
0
how to write coding for distance cos bearing formula in visual basic 6.0 and how to make bearing as input
0
Hi Experts,

I have the following calculation in VBA.

Dim Me.GRP_MAX_YTH_NBR As Integer.  Value = 3
Dim Me.GRP_MAX_LDR_NBR As Integer,  Value = 4
Dim Result As Long

Result = Me.GRP_MAX_YTH_NBR \ Me.GRP_MAX_LDR_NBR

The above calculation returns Result = 0

How do I get it to return a result of 0.75 which is the decimal equivalent the fraction 3/4?

Thanks,
Bob C.
0
Hi,

Then I open a form with acdialog it always autocenter the opened form, but the autocenter property is false. The moveable property is Yes and I do a me.move of postion left and top of a control of the opening form. I use the onLoad event me.move with twips for contol of opening form, Me.window.Left + me.Control.left and Me.window.top + Me.control.top.

What ever I change the number to of the move method it is still in the center. I would like to have it over the control since the popup form is associated to that control.

Thanks in advance.

BAnders
0
Is there any way to compile an .ocx file [a custom control created in visual basic 6] to an .apk file?
0
i want to log off computer after each 2 hours of processing how can i log off in windows 8.1 or windows 10 ( 64 bit)  node.
i have try  Shell "shutdown -l -t 00" but it is not working,

Thanks in advance.
0
Hello,

Please see the attached sample file.  The existing code works which splits out rows into separate workbooks based on an ID in column C.  Part of this code looks at specific IDs and if found groups them together and places them in a workbook called Ions.  

I am seeking assistance on modifying the code to replicate that process so if the macro also identifies rows with 000999 and 000998 then it places them into a workbook called Ions 2 and if it identifies rows with 000997 and 000996 then it places them into a workbook called Ions 3.

Thanks!
EE-Test-FileV2--1-.xlsm
0
Concerto Cloud for Software Providers & ISVs
LVL 5
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.

How to calculate ''32% Undergraduate Grade Point Average?
0
Hello,

How do you create a custom command, assign it an icon, and include it in the Quick Access Toolbar (QAT) in Excel (2010)?

As an example, [Ribbon > View > Show (section)] includes the option to show or hide (Row & Column) Headings.

I looked for that as an existing shortcut (to add to my QAT) by going to:

        File > Options > Quick Access Toolbar > All Commands

However, although I looked under [Headings], [Hide Headings], [Show Headings], and [Unhide Headings], I could not find it.

Can someone explain how to create a custom QAT shortcut for that function?

Thanks
0
Hi All,
I'm using MS Word 2010 need to add a date field (Report_Due_Date) that is calculated to greater than another date field (Report Generation Date).  Need to automatically run on document open.

Any ideas?

Thank you!
0
I am trying to write a query to work out the number of days my employees have worked since they started at the company and for the report have a column named DaysEmployed.

Any help would be greatly appreciated.
0
someone helped me with the code below.


it uses three different classes  CreateObject("System.Collections.ArrayList")  & With CreateObject("System.Collections.SortedList") and = CreateObject("Scripting.Dictionary")

i have seen previously Scripting.Dictionary"  but i have never seen the other two system.collections.arraylist and sortedlist.

i googled, only in microsoft support page there is a very little detail and no example. where and how it is used.

i need help with commeting the code below, that what line of the code does what.

also i need help if someone could lead me to somewhere where i can learn more about the two classes system.collections.arraylist and system.collections.sortedlist.  with example

Option Explicit

Sub Macro()
    Dim a, i As Long, ii As Long, AL As Object
    Set AL = CreateObject("System.Collections.ArrayList")
    a = Sheets("data").Cells(1).CurrentRegion.Value
    With CreateObject("System.Collections.SortedList")
        For i = 2 To UBound(a, 1)
            If (a(i, 2) <> 111) * (Not AL.Contains(a(i, 2))) Then AL.Add a(i, 2)
            If a(i, 3) Like "[5-7]*" Then
                If Not .Contains(a(i, 1)) Then
                    Set .Item(a(i, 1)) = CreateObject("Scripting.Dictionary")
                End If
                .Item(a(i, 1))(a(i, 2)) = .Item(a(i, 1))(a(i, 2)) + a(i, 4)
            End If
        Next
        ReDim a(1 To AL.Count + 1, 1 To .Count + 1): AL.Sort
        a(1, 1) = "Months/Years"
        For

Open in new window

0
Hi, Experts, I got a code from google that would be able to get serial number of the HD, and this work only on Windows Xp. I wish to revise the codeHDSLN-Demo.zip that would work also on  Windows 7 and 10. Is there anyone who can help me please.
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.