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 getting an "Input past end of file" with the code below...
            Set fsoIn = New Scripting.FileSystemObject
            Set fsoOut = New Scripting.FileSystemObject
            
            Set tsTxtFileIn = fsoIn.OpenTextFile(sPath & "rfid\putty.log", ForReading, False, TristateMixed)
            If fsoOut.FileExists(sPath & "rfid\" & iBox & ".txt") Then
                Set tsTxtFileOut = fsoOut.OpenTextFile(sPath & "rfid\" & iBox & ".txt", ForWriting, False, TristateMixed)
            Else
               Set tsTxtFileOut = fsoOut.CreateTextFile(sPath & "rfid\" & iBox & ".txt")
            End If
            
            With tsTxtFileIn
                Do Until .AtEndOfStream
                    If Left$(.ReadLine, 2) = "aa" Then
                        If Right$(.ReadLine, 2) <> "FS" Then
                        
Debug.Print Right$(.ReadLine, 2)

                            strIn = .ReadLine
                            strHex1 = CInt("&H" & Mid$(strIn, 33, 4))
                            strHex2 = CLng("&H" & Mid$(strIn, 9, 8))
                            If Not Left$(strHex2, 1) = "-" Then
                                strOut = Mid$(strIn, 4, 1) & "," & strHex2 & ",0," & _
                                         QUOTE & Mid$(strIn, 27, 2) & ":" & Mid$(strIn, 29, 2) & ":" & Mid$(strIn, 31, 2) & _
                                         "." & strHex1 & QUOTE & "," & Mid$(strIn, 4, 1) & ",0"
                                tsTxtFileOut.WriteLine strOut
 

Open in new window

0
Introduction to R
LVL 13
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Is there a way to write a script in vb6 to change the IPv4 ip address of a pc for the wired ethernet property?

Thank you!
0
I am trying, using VB6, to resize and save a .jpg with the largest side being 150px.

It has been so long since I've used VB6 that I'm having trouble figuring out how to start?

I think I used to do this using a command line and Imagemagick.
0
Hi Experts,

I've got a VB6 application (I am the author) that is crashing without a trace of anything, except a .dmp file (attached).
It crashes when running in the VB6 IDE or as a compiled .exe.

The only error message I can see is:

The thread tried to read from or write to a virtual address for which it does not have the appropriate access.
Heap Information:      Not Present

Here's the whole Dump Summary (opened in VS 2013):

Dump Summary
------------
Dump File:	HIPAVE.exe.6656.dmp : C:\Users\Leigh\AppData\Local\CrashDumps\HIPAVE.exe.6656.dmp
Last Write Time:	4/03/2019 1:20:56 PM
Process Name:	HIPAVE.exe : D:\Dev-Ver5.0\HIPAVE50\vb6\HIPAVE.exe
Process Architecture:	x86
Exception Code:	0xC0000005
Exception Information:	The thread tried to read from or write to a virtual address for which it does not have the appropriate access.
Heap Information:	Not Present

System Information
------------------
OS Version:	10.0.17134
CLR Version(s):	

Modules
-------
Module Name	Module Path	Module Version
-----------	-----------	--------------
HIPAVE.exe	D:\Dev-Ver5.0\HIPAVE50\vb6\HIPAVE.exe	5.0.0.732
ntdll.dll	C:\Windows\System32\ntdll.dll	10.0.17134.556
kernel32.dll	C:\Windows\System32\kernel32.dll	10.0.17134.556
KERNELBASE.dll	C:\Windows\System32\KERNELBASE.dll	10.0.17134.556
msvbvm60.dll	C:\Windows\System32\msvbvm60.dll	6.0.98.15
user32.dll	C:\Windows\System32\user32.dll	10.0.17134.376
win32u.dll	C:\Windows\System32\win32u.dll	10.0.17134.1
gdi32.dll	

Open in new window

0
Trident-Data-String-Identification-.docx I'm looking for a way to parse the data in the attachment as comma-delimited based on the color coding indicated.  The data would come as a plain text file and need to be parsed and saved as a plain text file.  This would be done using a vb6 application using the file system object.  Ideas?  Note that the strings are fixed length.
0
Using VB6, I have attached the following project.  It allows custom tool tips to display on a form when the cursor is placed over it.  The only problem is that the tool tips only display for about 5 seconds and then disappear.   I can't seem to see the properties where that can be adjusted.  I need some assistance.
Tooltips.zip
0
In VB6, is there a way to select a record from a datagrid and use the values in that record for coding.  For example, if you see the selected row in the attached image, I would like to use the values in the first few columns (Agency, ActivityName, etc...)  How would I select the values after the user has selected the row from the review grid?
image.jpg
0
Run-time error 2147319765 (8002802b)  Automation error Element no found

I use visual basic 6 in windows 7 to operates outside of an autocad 2007 program.  My visual basic program works perfectly well on some identical computers but throws the error noted above on two other similar computers!

The project is referenced to Autocad 2007 Type Library.

The program I wrote simply requests an autocad screen then asks the user to select a polyline.  The error then appears in the line highlighted in my code below:

Private Sub Command1_Click()
Dim plobj As AcadLWPolyline
Dim ssetObj As AcadSelectionSet
Dim myapp As AcadApplication
Dim mydoc As AcadDocument
Dim i As Long
Dim ent As AcadObject
Dim ppt As Variant
Dim pcount As Long
Dim clObj As AcadLWPolyline

On Error GoTo err:

''List2.Clear
''List3.Clear
''List4.Clear
''List5.Clear
''List6.Clear
''List7.Clear
''
''List8.Clear
''List9.Clear
''
''Grid1.Clear
''Text1.Text = ""
''
''On Error GoTo err:

Set myapp = GetObject(, "Autocad.application")
Set mydoc = myapp.ActiveDocument

    If mydoc.SelectionSets.Count > 0 Then
    mydoc.SelectionSets(0).Delete
    End If

Set ssetObj = mydoc.SelectionSets.Add("sent")

On Error Resume Next
AppActivate ("Autocad")
    If err Then
    Me.Show
    MsgBox "Is Autocad Runnning - it should be!", vbOKOnly, App.Title
    Exit Sub
    End If
            
On Error Resume Next

myapp.ActiveDocument.Utility.GetEntity ent, ppt, "Select Centerline: "[u] 

Open in new window

0
Trying to get Drag and Drop working for a vb6 application I maintain.  

I found this:
https://www.experts-exchange.com/questions/21897207/VB6-Drag-and-drop-file-s-onto-a-textbox.html

and created a test application to try it...

Only difference is, I used a listbox instead of a text box and used the code below
Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Data.GetFormat(vbCFFiles) Then
        
        Dim i As Integer
        For i = 1 To Data.Files.Count
            lstDrop.AddItem Data.Files(i)
        Next
        
    End If
End Sub

Open in new window


Unfortunately, the form doesn't seem to respond to the drag and drop events.  When I run the program and attempt to drop a file (.exe) onto it, I get a circle with a line through it indicating I can't do that.

OS is Win10 1809.  Any tips for making this work?  (I don't care if I used the code from the referenced EE question, though it's pretty simple and if I could keep it simple, I'd prefer that!)
0
We have an order management system that is based on VB6, runs in Access 2003. It currently has code (we wrote all of the program) which sends outgoing faxes from the system to a Castell Faxpress box we have. For incoming faxes, we have a home brewed OCR system built which converts all incoming faxes to a copy/pastable PDF.

Any ideas what out there nowadays could replace either or both of these? The boxes this stuff runs on need to be replaced and instead of doing that we want to at least step into the 2010's.
0
Price Your IT Services for Profit
Price Your IT Services for Profit

Managed service contracts are great - when they're making you money. Yes, you’re getting paid monthly, but is it actually profitable? Learn to calculate your hourly overhead burden so you can master your IT services pricing strategy.

I'm trying to determine the idle time of the system.  I was trying to use this code:

Private Type LastInputInfoType
    Size As Long    'Bytes
    Time As Long    'Dword
End Type

Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Function GetLastInputInfo Lib "user32" (plii As Any) As Long

Public Function IdleTime() As Long
    Dim LastInputInfo As LastInputInfoType
    
    LastInputInfo.Size = Len(LastInputInfo)
    GetLastInputInfo LastInputInfo
    
    IdleTime = GetTickCount - LastInputInfo.Time / 1000
    MainForm.Debug1Text = GetTickCount
    MainForm.Debug2Text = IdleTime
    MainForm.DebugText = "Time: " & LastInputInfo.Time & vbCrLf & "Size: " & LastInputInfo.Size
    
End Function

Open in new window


But it's not working.  When I put the variables in a text box to see what's going on, I'm getting numbers in the billions for both with the LastInputInfo.Time about 15-16 (varying) less than the GetTickCount value.  If I'm reading this, LastInputInfo.Time should be static UNLESS I'm using things... but it's always sensing activity and I'm not sure why...

I'm using a timer control to check every 100 ms - IdleTime is requested every timer cycle.

I'm open to other methods if anyone has them to detect idle time...
1
Hello experts,

I am looking for a procedure in order to insert multiple non empty column among non empty columns the requirement is the following:

1-Loop the various active columns
2-Inputbox insert the number of columns that you want to insert between empty columns.
3-Insert empty columns
4-Take as a reference the header of left column for inserted column


Example: Empty columns have been inserted for column A C E, left header has been parse for inserted column.

Insert-empty-columns.png
II attached dummy file.

Thank you in advance for your help.
Insert-empty-columns.xlsx
0
i am using vb6 and I have a textbox array and  I want to set focus to the next text box in the array when the user hit enter or tab
ie

Private Sub arrayText_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii >= 97 And KeyAscii <= 122 Then
    KeyAscii = KeyAscii - 32
End If

If KeyAscii = 9 Or KeyAscii = 13 Then
arrayText(I).SetFocus = True  
End If

End Sub

how do i know what i is?
0
I need to send email excel file when I select the drop down menu.
For example
if I select inprogress in column L I need to send email Saying that "Item XXXX (Taken from value of column E) Part# XXX (taken from Column I) Ticket#XXX (Taken from column K) quantity X (Taken from H)  is sent out for delivery"
And if I select delivered in column L I need to send email Saying that "Item XXXX (Taken from value of column E) Part# XXX (taken from Column I) Ticket#XXX (Taken from column K) quantity X (Taken from H) is delivered"

Attached the excel file for your reference.
Appreciate your help.
EVERNEX-STOCK--GT-REF-.xlsm
0
I am using VB6 to access a Microsoft Word template.  What I am perplexed on what to do is how to select a checkbox field as you can see from the attached image.  Currently Quarter 2 is selected.  How can I select Quarter 3.  I can bookmark the field, but I don't know the syntax for selection and checking the field.  Any help is appreciated.  


Here is some example code I am currently using in the document if that helps.

            objMSWord.ActiveDocument.Bookmarks(ObjectiveNumber).Select
            objMSWord.Selection.TypeText "ACTIVITY: " & rec!ActivityName & " - " & rec!ActivityType & "    " & rec!ActivityOther & vbCrLf
            objMSWord.Selection.TypeText "Identified Need: " & rec!Need & "    " & rec!NeedOther & vbCrLf
            objMSWord.Selection.TypeText "Objective Addressed: " & rec!Objectives & vbCrLf
            objMSWord.Selection.TypeText "Stated Strategy: " & rec!Strategy & vbCrLf
            objMSWord.Selection.TypeText "Outcome: " & rec!Outcome & vbCrLf
            objMSWord.Selection.TypeText "Narrative Summary: " & rec!Narrative & vbCrLf
            objMSWord.Selection.TypeText "-----------------------------" & vbCrLf & vbCrLf

Open in new window

example.jpg
0
Hello experts,

I have the following excellent procedure reported at: https://www.experts-exchange.com/questions/29133150 
Sub Remove_Last_Char()
 Dim c As Range
    Dim s As String
    Dim ProcessColumn As String
    Dim RemoveCount As Integer
    
    ProcessColumn = ""
    ProcessColumn = Application.InputBox("Please enter the column letter in which do you want to remove last characters", "Column To Process", Type:=2)
    If ProcessColumn = "" Then Exit Sub

    RemoveCount = 0
    RemoveCount = Application.InputBox("How many characters do you want to removed from the last to the beginning?", "Characters To Remove", Type:=1)
    If RemoveCount = 0 Then Exit Sub
    
    Application.ScreenUpdating = False

    For Each c In Range(ProcessColumn & "1", Range(ProcessColumn & Rows.Count).End(xlUp))
        s = c.Value
        If s <> "" Then
            If Len(s) > RemoveCount Then
                c.Value = Left(s, Len(s) - RemoveCount)
            Else
                c.Value = ""
            End If
        End If
    Next c
End Sub

Open in new window


I would like to take it as a reference in order to cover the following requirement:
-Instead of removing the last character I would like to ask: “Report the range in which is located the character & string that you want to remove from last to the beginning”.
The procedure should remove the last character if it is found. I use the following formula to cover this requirement:
=IF(RIGHT(A2;1)=".";LEFT(A2;LEN(A2)-1);A2) This means that if “.” Is found as last character it will be removed else A2 will be kept as it is.

If you have questions, please contact me.
Thank you very much for your help.
0
Hello experts,

I have the following procedure in order to remove last character.
I would like to add the following requirements.

Sub Remove_Last_Char()
Dim c As Range
Application.ScreenUpdating = False
For Each c In Range("A1", Range("A" & Rows.Count).End(xlUp))
If c.Value <> "" Then c.Value = Left(c, Len(c) - 1)
Next c
Application.ScreenUpdating = True
End Sub

Open in new window

1-Input box “Please enter the column letter in which do you want to remove last characters”
2-Input box: "How many characters do you want to removed from the last to the beginning?"
Report in next available column the modification performed by the procedure.

If you have questions, please contact me.
0
iSeries CPF5140  Telnet-session ends abnormal.

Telnet connection is from JBOSS server ( Applinx server ) to host (iSeries)
CPF5140 is caused by ending session without SIGNOFF.

Applinx has his own specific language base on librrary ( maybe java ).
    Input  parameters for CreateEmulationsession : UserName and password.
    Output parameter is sessionID
Please see attached file, skripting . . .

session may be disconnected and CPF5140 Joblog appears on iSeries Host.
Applinx Skript for session handling  
How to add SIGNOFF in Skript, to avoid CPF5140 ?

disconnect-instead-closing.PNG
0
Would like to do the following using VBA

A:  Find and Replace the values in named range ("BizClass"), with its corresponding value in another named range ("occupancy").

Sheet1, Column D = NamedRange "BizClass"
Occupancy Tab: Contains a list of matching data.

Objection: Find the value in "Biz Class" named range in the data in 1st column of "Occupancy" named range and replace it with the value that is in the 3rd column.
Find-Replace.xlsm
0
PMI ACP® Project Management
LVL 13
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

I have a visual basic function which calls a sql server viewand sets the order by clause to filter the by with something like this:

        SqlStr = SqlStr & " Order By "
        If Len(SortBy) Then
            SqlStr = SqlStr & SortBy & ", "
        End If
        SqlStr = SqlStr & "LastName, FirstName, MidInit"


In this if statement, it's using Len. I'm not familiar with that function.
https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/functions/string-functions

What is this if statement doing?

        If Len(SortBy) Then
            SqlStr = SqlStr & SortBy & ", "
        End If
0
how to put header with some thing like  "Design Document"
footer with something like Date save and time stamp
how to achieve in word
please advise
0
I have several applications that use a split function.   HOwever, in one of my applications, using the same code, I get the error 730 control xxx not found (xxx being the string I'm trying to split).  Here is the sample code i'm trying.
Dim s As String
s = "This is, a test of, splitting a string, to multiple strings"

Dim fields() As String

' Split the string at the comma characters and add each field to a ListBox
fields() = Split(s, ",")
Dim i As Integer
For i = 0 To UBound(fields)
    MsgBox Trim$(fields(i))
Next

This produces the error"  Run-time error 730, Control 'This is, a test of, splitting a string, to multiple strings' not found.
0
Hi Experts,

I need to have the following in a sub form within a main form.

From the table Patients_Daily_Medications

with the fields below.
PatientID
Medication
Day
TimeGiven
Sequence

I need a crosstab query that would show me Medications as column heading and sequence as row heading and TimeGiven as the values.

See attached what the data looks like, and what I am trying to accomplish (not completed as you can see...)

At the end I would need this query as the record source of a form that has a patientID and a date as fields, so this should only return values of a sibgle patient at a particular day.

PS- Note TimeGiven has a date+time, we need to extract the Time only.

PS -, a VBA function that will open a recordset of that table, Accept two params (PatientID,Day) and return the following would also serve the purpose.
ALBUTEROL: 9:00 AM, 11:00 AM      BUDESONIDE: 11:AM, 1:00PM, 5:00 PM      MIRALAX: 3:PM

Thanks in advance.
Untitled.png
Untitled1.png
0
I build a small project in vb.net and create an .exe and .msi to load onto another PC. No error when I compile it. I install it on to another PC ( 3 different) PC's and it never runs.

If I install it on the same PC or on another pc running different versions of VS I can get it to run.

What Am I missing?
0
On my continuous form I have a checkbox called "select".  This select field is tied to a question on the form. I have several questions in the table.
So in the detailed section it looks like:
question   [ ]  <= Checkbox "select"
question   [ ]
question   [ ]
question   [ ]
question   [ ]
question   [ ]
I only want the user to be able to check "two" of the checkboxes on this continuous form. If the user tries to select a third checkbox I need a msgbox to pop up and state that "only two checkboxes can be selected at a time and 'not' check that third box. This will force the user to uncheck a different previously checked box before they they are permitted to check a different box.  Wondering how I can do this?
Right now I placed an invisible textbox on the form and placed this code: =Count(IIf(Nz([Select],0)=-1,1,Null))      in the control source. This method doesn't really work for obvious reasons . I need to somehow place some code in the after update event of the checkbox to see if two checkboxes have already been checked on the continuous form and not allow the user to check into the third box until the user first unchecks one of the other boxes.

Any assistance with the code on this would be most appreciated!
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.