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

How do you write a Worksheet Selection Change to Hide rows before a start time and hide rows after the end time.
  My schedule starts at row 5 Column D.  It contains entries in 15 minute increments starting at 12:00am. and extends 11:45pm, row 101.
In B7 and B8 I have Start time Row: and End time Row, calculations.  So I know (form example) that if the start time is 6:00am then that is row 30 and If stop time is 19:00, then that is row 81.
  So what I would like to do is have a change event, that will (in the example above), Hide rows 29 through Row6, and Hide Rows 82 through Row 101.

This is variable because AB5 (work Start Time) and AC5 (work end time) can change, but the start time Row Count and End time Row count B7 and B8 will automatically update when AB5 and AC5 is changed. (I have already done that).

I hope this makes sense...
Thanks,
Norm
0
Should you be charging more for IT Services?
Should you be charging more for 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 using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

I have a vb classic two-dimensional array called Arr(2, i).  It is currently sorted by the third element (index 2).  I want to sort it by the first element (index 0) and then keep it sorted within index 0 by index 2.  In other words, if the array consisted of:

Arr(0, 0) = 1
Arr(1, 0) = x
Arr(2, 0) = 100

Arr(0, 1) = 2
Arr(1, 1) = x
Arr(2, 1) = 200

Arr(0, 2) = 1
Arr(1, 2) = x
Arr(2, 2) = 300

Arr(0, 3) = 2
Arr(1, 3) = x
Arr(2, 3) = 400

I would like it to be sorted into this:

Arr(0, 0) = 1
Arr(1, 0) = x
Arr(2, 0) = 100

Arr(0, 1) = 1
Arr(1, 1) = x
Arr(2, 1) = 300

Arr(0, 2) = 2
Arr(1, 2) = x
Arr(2, 2) = 200

Arr(0, 3) = 2
Arr(1, 3) = x
Arr(2, 3) = 400
0
I am writing a windows forms application. One of the windows forms has an edit text box control on it. If I tab outside of this particular edit control, I would like the "tab-out" action to be interpreted as the user pressing the enter button. I believe that there is a Lost Focus event for the text box control, so possibly I can check for that event. What I need to know is how to force an "Enter" event when the tab out (Lost focus) event occurs.

Does anyone know how I could cause the "Enter" event to occur when the focus changes?
0
I want to determine if there is an open VNC connection to the host PC from inside my VB6 app. How can I do this?
0
I have a form which is used for two purposes, Quoting and Job Costing. There is a combobox to select which either of these options.

On the form is a Combobox (allow Inserts) which looks up a table of parts we are likely to use again a job.

If "Quoting" is selected we pick the item from a pre-populated table, then obtain a price from a supplier.

If, however, it is a "Job Costing" (i.e. the job has been carried out) we want the combobox to select from the table of parts used (which will have the cost we paid already available).

Thanks in anticipation
0
In other postings here, I learned (from Vadim Rapp) that I should pay attention to where components of a program are installed. Programs should go to Windows Program folders. Files of data that are read from and written to should go to Windows Data folders.

I am maintaining a legacy program that I created using VB6 a long time ago. Here is a list of files to be installed for this program. Please check my sort between "Program" and "data" folders.

PROGRAM FILE FOLDER:
4 .exe
1 .ico
2 .bmp
14 .txt Read only. Two are assembled into coded matrices. 12 are "Help" files.
1 .OCX regestered by the installer.

DATA FILE FOLDER:
Eleven data files that are program modifiable.
Some are text and some are Excel spreadsheets.
The Excel spreadsheets are "mission critical." To prevent users from getting in there and messing things up, I gave them the suffix ".sdp" which is not recognized by Windows (but is recognized by my program). These have to be replaceable by a set from this program run on a different computer.

I use Inno to build the installer. Here are two Inno script lines. The one for the OCX is different from all the rest.

Source: "F:\SS_Build\DataCalendar.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "F:\SS_Build\MSFLXGRD.OCX"; DestDir: "{app}"; Flags: restartreplace sharedfile regserver

Now (finally) to my questions:

(1) "DestDir" was established by Inno during creation of the installer. There has to be a way to specify two different …
0
I have a vb6 program that takes data from SQL and puts it into an excel sheet.  One of the SQL fields has A LOT of text in it and when it pastes into the excel field I get an "application defined or object defined error"  There are about 2400 words in the field.  It seems I traced it to the fact that there is too much data in the one field being placed into the excel field.   Does that sound too large for the field or any other observations?  If its too big, what are the limits on size?
1
I am maintaining a legacy app I wrote in VB6 a long time ago. Development is done on
an external hard drive that I switch between two machines, XP for development, and
Win7 to test run. I use Inno to build the installer. Installer works successfuly all
the way up through Win10. Installation occupies a shade under 1 MB.
All required associated files for the project, and four compiled executables
(including the new one) are gathered  on the external hard drive in a folder named
"SS_Build".

I was asked to add a feature (MakeNewPlayers.exe). An Excel spreadsheet is read in,
modified, and written out. Works perfectly in development mode. Works perfectly when
executed from the Build folder under XP. Works perfectly when executed from the Build
folder under Win 7.

Doesn't work from the installation created by Inno. Program stalls near the bottom,
where the modified Excel spreadsheet is written out. The message box does not appear.
If I exit, system asks me if I want to save "Book1", which tells me the modified
spreadsheet actually was created (but apparently not named), confirmed by looking at
"Book1".

Here is the relevant source code:

Set oXLApp = CreateObject("Excel.Application")
If oXLApp.Application.Version > "11.0" Then
    iXLversion = 56
Else
    iXLversion = -4143
End If
Set oXLApp = Nothing

Set oXLApp = CreateObject("Excel.Application")
(code that modifys spreadsheet goes here)

SavePath = App.Path & "\" & sWorkbookName

Open in new window

0
What is the best way to have a timer displaying the running time of a race (or several races) in vb6.  Let's say that one race started at precisely 8:00:00 AM and a second race started at 8:14:56 AM.  I would like a display on our results page that continually shows the elapsed time of each race (h:mm:ss would be fine).  I could use a quick blurb of pseudo-code if anyone has the time.  I could figure this out but I want it to be as "efficient" a utility as possible because results and other functionality will be occurring throughout the duration of the event.

Thanks in advance!!
0
Dear Team,

I have the below vba code to insert bullets with customize formats and alignment. Now I am looking forward to the incorporate the following below mentioned actions  in the code .

Please note that slide contains 2 text placeholder one for the Title and other for text


1. Reposition my text placeholder having (Top=75, Left=90,Width=739 and Height may vary depending on text.To have more clarity for the position of text placeholder I have appended below the image of shape dimensions from Microsoft power point 2016.


2. the text inside the placeholder should be calibri , size 12 & color (R=89,G=89,B=89)

For the size and margins to be freezed I am attaching an image for better clarity.



I need to collate this action with the below mentioned codes to have alignment of text and bullets


Sub Mybullets()

Dim pghcnt As Integer

With ActiveWindow.Selection.TextRange

.ParagraphFormat.bullet.Font.Name = "Wingdings"

.ParagraphFormat.bullet.Character = 167

.ParagraphFormat.Alignment = ppAlignJustify

.ParagraphFormat.bullet.Font.Color = RGB(89, 89, 89)

.ParagraphFormat.bullet.RelativeSize = 0.75


End With

For pghcnt = 1 To Windows(1).Selection.TextRange.Paragraphs.Count

Windows(1).Selection.TextRange.Paragraphs(pghcnt).IndentLevel = 1

With Windows(1).Selection.ShapeRange.TextFrame.Ruler

.Levels(1).FirstMargin = 7

.Levels(1).LeftMargin = 20

End With

Next

End Sub

Open in new window

Further the layout contains title and content placeholder.

Please help me to collate the text part as well.

Thanks in advance

Regards
Dilpreet Singh
content.PNG
0
Amazon Web Services
LVL 13
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

i have two different server having SQL server 2014. it has two different IP address. I can create ODBC to both server. when i try connect two different database on different server , i got the message ODBC SQL SERVER - INVALID OBJECT NAME in vb6 application,  I can open database on local server. but cannot open file on different server with different IP address.  What could be the problem. how can solve this problem. Thanks in advance.
0
How can I authenticate the User ID and Password to be valid from VB.Net and VB6 programs with Windows 7 Active Directory?
0
How do I pass an object as a parameter in vb6 when calling a sub?  I want to create a sub that will execute an ftp script in a module but the Inet object is in the form.  I should know this but...  Also, is that ByVal or ByRef?  I assume ByRef?

Thank you in advance!
0
I need to access data from a race timing machine via an ethernet connection as runners cross the finish line.  I have a TelNet connection that is working but I am not sure how to keep it from timing out.  In my search for a solution to that I have been directed to SSH.  I have open SSH installed on my Windows 10 machine.  How can I connect my timing box with my PC using a vb6 program.  This piece is all very new to me.

Thanks for your assistance!
0
I have a TelNet utility in my vb6 app for race timing to get finish times from my timing machine to my computer.  It has been working well but at the last race (one of the first I have used it for) it stopped sending data after about an hour.  Is there typically a time-out feature in TelNet and, if so, how can it be adjusted?  I can post the code if need be.
0
I have Excel 2016 and I need to have this statement executed on 540 rows.  How would I set this up to be applied to all of those rows?

=SUBSTITUTE(SUBSTITUTE(B$1,"before-value",A3),"after-value",B3)

Open in new window


This creates a statement out of the combined rows.  Currently, I have to increment the cell values manually for each pair.
1
Hi all, I'm trying to make a program that picks up scanner codes from a hand scanner device that's plugged into a USB port on a Windows PC.  I'm writing it in Visual Basic 6 because it's still my favorite program for making quick apps like this.  The hand scanner just sends the string of text that's in the code to the PC, and it sends it very fast.  To start out, I made a pretty simple program just to see if it's possible to catch all the characters fast enough and I'm having trouble with that part.  It seems to grab random characters and I can't go lower than 1 ms on the timer.  

I need it to be able to grab the characters from the keyboard buffer even if it's not the program that's in focus so I used the GetAsyncKeyState function from windows api.  Here is my form code that isn't catching all of the characters:

Option Explicit

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

Private Sub Command1_Click()
    Label1.Caption = ""
End Sub

Private Sub Timer1_Timer()
    Dim nKey, nChar As Integer
    Dim nText As String
    For nChar = 16 To 255
        nKey = GetAsyncKeyState(nChar)
        If nKey = -32767 Or nKey = -32768 Then
            nText = CStr(nChar) + " "
            Label1.Caption = Label1.Caption + nText
        End If
    Next
End Sub

Open in new window


All I have on the form are a label, buttons, and timer with a 1 ms interval. The label1 will show a few random character codes from the code after I scan one. Does anyone have advice for making it catch all the characters from the hand scanner?  I also tried it with GetKeyState and it had the same problem.
0
Hello Experts
I have an old application (VB6) running on Windows 10 x64
The program works fine after installation until I restart the PC
Then the program refuses to work until I remove it and re-install it again. And also to reboot the device and so on.
the error message ( Unsupported value type:1001:error)
0
I am trying to connect a race timing system to my race timing software on my PC via Microsoft Internet Transfer Control 6.0 inn a vb6 app connected via ethernet.  I have the framework in place but there is something missing...maybe lots of things.

Here is what I know and have created with my program:
1) The remote host is 192.168.1.102 (This is sRemotePath in the code below)
2) The file I want to download is called "filtered.log" (This is sWhichFile in the code below.

My program correctly assigns these two variable values.

My local path (where I want the file downloaded to) is correctly identified as sLocalPath

Here is my code.  Please tell me what is missing in terms of connecting;
    sWhichFile = lstWhichFile.Text
    
    sRemotePath = "192.168.1." & iWhichTimer
    sLocalPath = sPath & "rfid\"
    
    Inet1.url = sRemotePath
    Inet1.UserName = "anonymous"
    Inet1.Password = vbNullString
    
    Inet1.Execute , , "get" & sRemotePath & sLocalPath & sWhichFile

Open in new window


Thank you!
0
Expert Spotlight: Joe Anderson (DatabaseMX)
LVL 13
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

I have speakers plugged in and recognized because audio is playing out of them on the 3.5 mm audio (headphone) port on my windows 10 pro tab.  However these speakers are not appearing in the playback tab of the "Sound" setting of the control panel nor are they found in either "Sound, video, and game controllers" or "Audio inputs and outputs" of the control panel.

What is found under:

Audio inputs and outputs:
Microphone (Intel SST Audio Device (WDM))
Speakers (Intel SST Audio Device (WDM))

Sound, video, and game controllers:
Intel SST Audio Device (WDM)
Realtek I2S Audio Codec

Playback tab of the Sound setting in the control panel:
Speakers Intel SST Audio Device (WDM)
Default Device

Also, none of these settings change when these speakers are plugged into this 3.5 mm audio (headphone) port.

What I would like to do is, using Visual Basic 6.0,  when a command button is clicked (cmdSound1_Click()), have a message (msgbox) that reads simply if there is a device installed in this  3.5 mm audio (headphone) port.  For example "Hardware found in audio port" or "No Hardware found in audio port, please be sure that the speakers are powered on before trying again."
0
Does anyone know of a free vb6 program that can connect to a remote source via ftp?

Thank you!
0
How can I open multiple instances of the same form in vb6?  I need a TelNet window for each timing box that I am using so I need my TelNet window to open multiple times.

Thanks!
0
I am incorporating a TelNet utility into my vb6 program.  I have never done anything with TelNet.  The utility I am using is this:  http://www.freevbcode.com/ShowCode.asp?ID=2839

I am using it to get data from a timing machine into my timing software in near-real time...constant stream as runners finish.  Here is what i need to know:

1)  Is there a limit to how much a TelNet client can log?  We will often have 15,000 reads to process....occasionally more.

2) Is there a limit to how much "density" a TelNet client can log simultaneously.  We could easily have 50-100 folks finish in a minute and each one of them typically generates 2-4 RFID reads.

3)  What do I do if I need to get data that is in the source file before I start the TelNet client?  In other words, it is not unusual to carry the timing box to a different place for the race start than where we set up for the finish.  We typically carry our timing box to the start, get all the start reads as the race starts, and then carry the timing box back to the finish and re-connect our timing mats.  How would TelNet get me that data?

Thank you very much!
0
Can I open one vb6 program from another vb6 program and have them both run simultaneously?
0
I initially had the code to do the following :
Compare the ranges between between sheet1 and sheet2 , when they have unique values and they are below the specified date ( March 25th , 2019 ) , the record should get deleted in sheet1 and when it above the specified date then the record should get copied below the last row of sheet1.
Option Explicit

Sub Operation()
    Dim Sheet1 As Excel.Worksheet
    Set Sheet1 = ThisWorkbook.Sheets("Sheet1")
    
    Dim Sheet2 As Excel.Worksheet
    Set Sheet2 = ThisWorkbook.Sheets("Sheet2")
    
    Dim SpdDate As Date
    SpdDate = DateSerial(2019, 3, 25)    '// DateValue("March 25,2019")
    
    DeleteOldTasks Sheet1, SpdDate, Sheet2
    InsertNewTasks Sheet2, Sheet1
End Sub

Private Sub DeleteOldTasks(ByRef Target As Excel.Worksheet, ByVal dt As Date, ByRef Source As Excel.Worksheet)
    Dim LastRow As Long
    LastRow = Target.Cells(Target.Rows.Count, 2).End(xlUp).Row
    
    Dim i As Long
    For i = LastRow To 2 Step -1
        Dim rng As Excel.Range
        Set rng = Target.Range("B" & i & ":C" & i)

        If (rng.Cells(2) < dt) Then
            If Not (TaskDateExist(Source, rng)) Then
                rng.Cells(2).EntireRow.Delete
            End If
        End If
    Next
End Sub

Private Function TaskDateExist(ByRef Source As Excel.Worksheet, ByRef rng As Excel.Range)
    Dim LastRow As Long
    LastRow = Source.Cells(Source.Rows.Count, 2).End(xlUp).Row
    
    Dim i As Long
    For i = 2 To LastRow
        Dim 

Open in new window

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.