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 trying to write a billing program. i know only vb6. while the user starts typing the item name (i use text box) the search beigns character by character and populates the listbox. i scroll down the populated list and the item name i wanted gets highlighted. now how can i populate the highlighted item. i dont want to use mouse clicks.

basically i wanted help with search as you type and populate the text box with the highlighted item.
0
Technology Partners: We Want Your Opinion!
Technology Partners: 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!

Hello Experts

I have old Crystal Reports version 4.0 Pro developed by the ton and they are most of them called from old VB3 program and worked fine ever since.

Today one of my staff reported that they keep getting the Error 20500 Out of Memory on a specific report under specific criteria selected. They run Win 7 32 bits. We tried an other chap at the office and they got the same error too on the same report. Mind you all other reports works fine and this report is not memory hungry. What it does is when you launch the report from the VB program you get the preview window and the records starts rolling up to a point when you get this error. I ran it a couple of time to see if it is related to a specific record but NO it throw the error every time at a record count different.

I thought that maybe I should increase the MaxbufferSize of Jet in the registry under Jet 2x but this did not help, any clue here ???

I tried the same report on my machine Win 7 64 bits (under the Virtual Machine running XP) and the report ran fine with no error whatsoever.

I have been all day checking all about this error on the Net and have done all possible but can't find anything that fixes it.

The database used in the VB3 is MDB Access 1.0 or 1.1 or 2.0
0
I had this question after viewing Run macro after mail is sent.
0
This app written in VB.Net w/Visual Studio 2010) is executing a thirty-part function inside a background.worker (see Private Sub bgwKeyPad_DoWork) and is triggering a function that update a textblock container (see Private Function RetFunKey(resultkey As String) As String).

The execution of that RetFunKey results "Cross-thread operation not valid: Control 'txtkey1' accessed from a thread other than the thread it was created on."

How can I solve this problem? Thanks in advance.



Private Sub bgwKeyPad_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles bgwKeyPad.DoWork
    .
    .
    Dim RetFunKey As New ClassPosCOM.POSCommunication.AsyncRetKeyPress(AddressOf Me.RetFunKey)
    pinOne = pinp.AsyncPinblockMessage(kpCom, tTarjetaSel, RetFunKey)
    .
    .
EndSub

Private Function RetFunKey(resultkey As String) As String
    '**************************************************
    '** resultkey = cantidad de asteriscos a dibujar
    '**************************************************
    txtkey1.Text = ""
    txtkey2.Text = ""
    txtkey3.Text = ""
    txtkey4.Text = ""
    Select Case Val(resultkey)
        Case 1
            txtkey1.Text = Chr(149)
        Case 2
            txtkey1.Text = Chr(149)
            txtkey2.Text = Chr(149)
        Case 3
            txtkey1.Text = Chr(149)
            txtkey2.Text = Chr(149)
            txtkey3.Text = Chr(149)
        Case 4
            txtkey1.Text = Chr(149)
         …
0
I had this question after viewing excel formula to move to next row if cell is blank, if cell not blank return answer in different column.

Very similar request except on my sheet there are 3 cells (QTY) that could be populated within each row (Manage, AID and SmartEscalate)

I tried a riff on the original code but I am afraid I wasn't able to get it to work.  

I have a tab for as-is and to-be


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Dim ws As Worksheet
Dim r As Long, lr As Long
Application.EnableEvents = False
Set ws = Sheets("ORDER")
If Target.Column = 7 And Target.Row > 4 And ActiveSheet.Name <> ws.Name Then
    If ws.Range("C5").Value = "" Then
        lr = 5
    Else
        lr = ws.Range("C" & Rows.Count).End(3)(2).Row
    End If
    If Target <> "" Then
        Range(Cells(Target.Row, "C"), Cells(Target.Row, "I")).Copy ws.Range("C" & lr)
    Else
        Application.DisplayAlerts = False
        If WorksheetFunction.CountIf(ws.Columns(3), Cells(Target.Row, "C")) > 0 Then
            r = WorksheetFunction.Match(Cells(Target.Row, "C"), ws.Columns(3), 0)
            ws.Range("C" & r & ":I" & r).Delete shift:=xlUp
        End If
        Application.DisplayAlerts = True
    End If
End If
Application.CutCopyMode = 0
Application.EnableEvents = True
End Sub

Open in new window

Price-Catalog-Quoting-20171016.xlsm
0
Hi

I am looking for a VB script that would allow to type full name or users name in a search box that would run against certain LDAP groups (43 groups) to confirm if the user exists. If the user exists the output should be display on the screen and save in CSV file.

These 43 groups exists in AD (LDAP).

Thank you, M
0
I have a visual basic 6 form  with regular  buttons  ie
cmdAdd
cmdUpdate

My requirement is to allow different user  during login
to have a button have specific properties i want for that buttonand  for that user

What I have done is to create  a table   containing the following fields and  sample values see attached

When user "MASTER"   runs a form i call  runinvoices  I am able  to  read the table and set

string6 = runinvoices.cmdAdd.Enabled =  '1'

from the string  below

string6 = string2 & "." & string3 & "." & string4 & " = '" & Trim$(string5) & "'"

The problem i have is how do i get my form  to execute   runinvoices.cmdAdd.Enabled =  '1'

which would enable the cmdAdd  for this user

Another  User may have  runinvoices.cmdAdd.Enabled =  '0'

saying  disable the Add command button for the other  user

My question is:

Am I  doing the right thing to be able to have diffrent button properties react
differently  to different  users ??

If yes  how do i get the form during form load  to  recognise  the value  of  runinvoice.cmdAdd.Enabled = '1

If I can not get this to work how can i achieve  this functionality

Thanks  

Oluwole'
buttonproperties.PNG
0
Hi experts,

I have 2 questions on my app which I put at the bottom of this post.

I'm have a vb6 application. Yes you heard right a vb6 application.
I'm using sql server 2008.  I'm using the Employees table from the Northwind sql server database.
I'm learning to work with Recordsets.

I have a sql server stored procedure that looks as shown on this script:

USE [Northwind]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[GetEmployeeByID]
	-- parameter
	@EmployeeID as varchar(50)

AS
BEGIN					

SELECT [EmployeeID]
      ,[LastName]
      ,[FirstName]
FROM [Northwind].[dbo].[Employees]
WHERE [EmployeeID] = @EmployeeID 

END

GO

Open in new window


So when I execute this stored procedure like this on sql server management studio this is what the result set of the stored procedure looks like:

-- execute stored procedure and pass value of 2 to EmployeeID parameter
[Northwind].[dbo].[GetEmployeeByID] 2

Sql1.PNG
This is my code for my application. It works fine.

Option Explicit On
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cmd As ADODB.Command
Dim strconnect As String
Dim VarEmployeeID As Long

Private Sub btnGetEmployee_Click()

    ' get value in EmployeeID textbox and save in variable
    VarEmployeeID = txtEmployeeID.Text

    'Call the Function - pass the argument to the function called GetAnswer
    'the result is stored in a variable called the answer
    Set rs = 

Open in new window

0
I have a timestamp field named quote_created for when the record was created. I also have a field named send_email in that record.

If the quote was created more than ten minutes ago AND send_email=1, I need to be notified via email. We have Exchange 2007.

Possible?
0
I'm using VB6 and sql server 2008.

I created a sample app using a function call.
It works fine and looks like this. Gets the some of some integers.
So the function i'm using returns an integer.

p1.PNG
This is my working code

Option Explicit

'declare variables
Dim varfirstnumber As Integer
Dim varsecondnumber As Integer
Dim varanswer As Integer
Dim theanswer As Integer

' the click event for the Get Sum textbox
Private Sub btnGetSum_Click()

    'get value of the 1st number text box and store it in a variable
    varfirstnumber = txtNumber1.Text

    'get value of the 2nd number text box and store it in a variable
    varsecondnumber = txtNumber2.Text

    ' sum numbers and store into variable
    'varanswer = varfirstnumber + varsecondnumber

    'Call the Function - pass the 2 arguments to the function called GetAnswer
    'the result is stored in a variable called the answer
    theanswer = GetAnswer(varfirstnumber, varsecondnumber)

    'display answer in label
    lblAnswerTextValue.Caption = theanswer

    'display answer in message box
    MsgBox "The answer is: " & theanswer
    Exit Sub

End Sub

' A function named FutureValue that requires 2 arguments
Private Function GetAnswer(Param1Number1 As Integer, Param2Number2 As Integer) As Integer

    GetAnswer = (Param1Number1 + Param2Number2)

End Function

' On Form Load event
Private Sub Form_Load()

    ' set label on form load - good
    'lblAnswerTextValue.Caption = 1

End Sub

Open in new window



In my example above the function returns an integer.

If I setup a function that calls a sql server stored procedure and than puts the table returned by the stored procedure into a record  set.

What it the syntax for my function so that it returns the recordset?

Then what is the syntaxt to call that function which is returning the recordset?

Anyone know?
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.

I'm using vb6

I have a sql server stored procedure that returns a column called TestColumn1.
This column of data type integer.

in my vb6 code i'm getting the stored procedure result and putting it in a recordset.

Sometimes it contains numbers and the stored procedure result is like this:

TestColumn1
1
4
5
12

Other types it contains no records and the stored procedure result is just like this:

TestColumn1


Right now i have the if statement below.
If there are results display appropriate message. If there are no results display the other message
   
    ' my recordset
    Set myrs = cmd.Execute

 If Not myrs.EOF Then
        If myrs.Fields(0) Is Nothing Then
            MsgBox "You got no records."
        Else
            MsgBox "You got some records."
        End If
 End If
   


Right It works ok for when my stored procedure returns records.
But i'm not sure how to check for Null values and the syntax for that inside an if statement.

Anyone know the correct way to check for a null value with an if statement in vb6?
0
Hi,

I have the following code called to execute on_click in an Access database.  It has worked fine so far and sends an email without the user being prompted by Outlook.  However, some people have recently been updated from Outlook 2010 to 2013 and the emails are no longer being sent.  I have a separate code that sends emails (with user prompt) and that is working fine regardless of Outlook version.  The database was created in Access 2010 and almost everyone uses Runtime 2010 to use it.  Can someone please tell me if there is a compatibility issue at work here or something like that?  Please note I replaced the outgoing email addresses with "XXXXXX" for privacy reasons.  Thanks very much for your help.

Baron

Public Sub SendMailCCPT()

    
    'Late binding
    Dim olapp As Object
    Dim olmail As Object
    Const olmailitem As Long = 0
    
    Set olapp = CreateObject("outlook.application")
    If olapp Is Nothing Then
        MsgBox "Outlook is not open. Please open Outlook and try again."
    Else
    Set olmail = olapp.CreateItem(olmailitem)
    With olmail
        .To = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        .Subject = "Project or Training Impacting " & Forms!EditSchPT!txtMyDept & " on " & Forms!EditSchPT!txtDate
        .body = Forms!EditSchPT!txtMyName & vbNewLine & Forms!EditSchPT!cPTDesc1 & ": " & Forms!EditSchPT!txtPTDesc1 & vbNewLine & "Start: " & Forms!EditSchPT!txtPT1St & vbNewLine & "End: " & Forms!EditSchPT!txtPT1End
        .Send
    

Open in new window

0
Experts,

Running into a problem with a legacy application.  Access 2003 runtime on Win 10 pro client PC's.

The method is failing with a run-time error 3275 "Unexpected error from external database driver (1)"

Example:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "[qryObjectName]", "C:\Folder\Filename.xls", True

Trouble began after MS Updates for the 2017-10 Cumulative Update for Windows 10 Version 1703 x64-based Systems (KB4041676)

Rolling back the update resolves the issue for now... but I'm looking for a practical fix.

Thanks in advance
Shawn
1
Hi,

How can i create a msgbox that will pop up 3 months before the following January 1st of every years?

the msgbox can say "January 1 will be in 3 months"


thanks for your help
0
Hello,

Where is the setting to always show currently-running/open Excel files in a pop-up list from the taskbar rather than as a row of thumbnail images?

When I left-click the Excel icon on my taskbar, it displays a row of thumbnails across the bottom of the screen. I can see the advantage in that since you can sometimes find a particular sheet more quickly that way. However, most of my Excel files look similar and the disadvantage to the thumbnail view is that part of the filename is commonly obscured. For me, this more than negates any advantage gained by the thumbnails. A pop-up list replaces the thumbnails once there are too many to display across the width of the screen, but "too many" is around 16-20 which is many more than I typically have open.

I am running Excel 2010 and at some point in the past, it was configured to never show thumbnails but always show a pop-up list, even if only a handful of files were open. Can someone help me locate that setting?

By the way, I am not referring to the "Recents" pop-up list which appears when you right-click the taskbar icon.

Also, it just dawned on me that this is probably an Office setting (or even a Windows setting) rather than specifically Excel and it may require going into the Registry. I think that's what it's called (the place you don't want to go unless you really know what you're doing). Btw, OS is Windows 10.

Thanks
0
I've been working on a program using VB 5 for a long time. I've used it over the years and it's always worked fine. I'm now on Windows 10 and VB5 still works, but when I try to use the Application Wizard to distribute the program, I get multiple errors. Does the VB5 Application Wizard still work? Is it possible to bring VB5 code into a more modern version?
0
above code about FOR..working truly if a vb6 return one project. .But project two or more..not working. and parameters interfere each other..what offer..what do you think..?

Public Sub ForluGercekİslemler1(ByVal frm As Form, ByVal Index As Integer, _
                ByVal ForProgBaslx As Integer, ByVal ForProgBitsx As Integer, _
                ByVal forSatirSayisi As Integer, ByVal Progbasl As Integer, ByVal Progbits As Integer)
                                        
                                                                Dim i11, i12 As Integer
                                                                Dim i21 As Integer
                                                                Dim i31, i32, i33 As Integer
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        If Tmr100(Index) = True Then GoTo 2 'Program ilk başladığında
        If Tmr100(Index) = False Then GoTo 4 'Başka programlarla ortak çalışmaya geçildiğinde
2
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

For i11 = 1 To 25
    for1StepDondu(Index, i11) = False
    syxFor(Index, i11) = 0
    forStepSay(Index, i11) = 0
    forI1Sw(Index, i11) = False
    for1DonguSw(Index, i11) = False
    forI1(Index, i11) = 0
    forTO1(Index, i11) = 0
    forSTP1(Index, i11) = 1
    StepNegtFor(Index, i11) = False
    StepPoztFor(Index, i11) = False
    forSatir3(Index, i11) = False
    SatirTekrarlamaFor(Index, i11) = 

Open in new window

0
I use the FSO File object to read large file sizes in VB6 where the Filelen function won't work. Does anyone happen to know the maximum size it will read? I wrote a program to write to a file and increase the file size in a loop,  reading the size each time it was written to, and the File .size was working fine until my hdd ran out of space, the file was 85.8 GB at that point.
TIA,
Mike
0
Good day,

Can you take a look of my code, why isn't working? I'm trying to make my customize Form and I put a picture box for Minimize, maximize/restore and close buttons...

    Private Sub PictureBox7_Click(sender As Object, e As EventArgs) Handles PictureBox7.Click
        If Me.WindowState = FormWindowState.Maximized Then
            Me.Size = New Size(1352, 724)
        Else
            WindowState = FormWindowState.Maximized
        End If
    End Sub

Open in new window

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!

Hey,

I have a lot of presentations used as templates, and I have data that I'd like to replace systematically.  For example, if I set the Title property to "Killer Presentation" I want everywhere in my PPT template that has "[Title]" to be replaced with "Killer Presentation."  But I want to be able to use any of the property fields (title, created, etc including custom property fields).

I found a solution that appears to be exactly what I want in the answers to this posting: https://superuser.com/questions/142012/powerpoint-how-to-insert-document-property-aka-field-in-slide/637624#637624

Problem is I used this code in a presentation to test, and while it runs, I don't see any results. Maybe this has something to do with the fact that I'm using PPT 2016, but I'm very new to VBA and I don't see where the issue is, and I'm not getting any errors to troubleshoot.

Anyone have any insight into the solution posted by P.Boothroyd in the post linked above?  And if I need to paste the code here, I can do that, if it makes it easier.

Thanks!
0
Customer ID is the primary key. I put already existing entry in the textbox it should say it already exists and not allow the user to put it.
Untitled.png
0
Working on a vb6 program to select dates between start date and x number of days out.
 I need to display the calendar for the time period selected with the start date +1 to the end day with it  bold and highlighted
I got something going but when I try to enter the next set of days the first day from the previous selection stays highlighted.   I am also wanting to push back the date if it lands on a Saturday or Sunday.  I have attached the program if you care to take a look.  it is kinda spaghetti code.  Any ideas would be greatly appreciated.
TATDate.zip
0
This code looks up all groups for the identified user account in a column,  I would also like to add the Account status so can tell if account is  Normal.

 If strLockStatus = 512 Then
 AccountStatus.Text = "Normal"



On Error Resume Next
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

If UserString <> UserObj.Name Then GoTo SkipBuild

For Each GroupObj In UserObj.Groups
ActiveSheet.Cells(intRow, 1).Value = GroupObj.Name
intRow = intRow + 1
Next

GoTo SortList

Open in new window

0
I want to make a copy of a text file with the following types of records with the intention of deleting unwanted records.  I will then kill the original and re-name the new file the same name as the original.  I am using vb6.  My plan is to write the desired records to an array and not the ones I don't want.  I can make each row an array entry, compare it to the entry i don't want (stored as a variable), and if there is not a match, write the record to the new file.  My concern is the quotes.  Is my plan a good one and how do I handle the quotes?

1,5700,0,"06:43:39.929",1,1
1,5700,0,"06:43:50.666",1,1
1,5700,0,"06:43:53.509",1,1
2,5700,0,"06:44:09.176",1,2
4,5700,0,"06:44:11.623",1,4
4,5700,0,"06:44:15.673",1,4
1,5700,0,"06:44:28.100",1,1
1,2997,0,"07:23:41.460",1,1
1,5700,0,"07:52:17.332",1,1
1,5700,0,"07:52:26.460",1,1
1,4696,0,"08:04:57.187",1,1
1,4695,0,"08:04:56.948",1,1
1,4696,0,"08:04:59.500",1,1
1,4695,0,"08:04:59.420",1,1
1,4695,0,"08:05:12.446",1,1
1,4695,0,"08:05:15.687",1,1
1,4696,0,"08:05:14.446",1,1
1,4695,0,"08:05:19.928",1,1
1,4695,0,"08:05:20.698",1,1
1,4695,0,"08:05:23.571",1,1

Thanks in advance!
0
Hi Experts,
Just wondering, I have a text box bound to expression
=[LastName] & ", " & [FirstName] & " " & [MiddleInitial] & " - " & [Title]

Open in new window

And i have a record with all fields entered except for middle initial, but for some reason the textbox is only showing the last name.
Any Idea?
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.