Quantcast
Channel: VBForums
Viewing all 42110 articles
Browse latest View live

Getdefaultprinter problems

$
0
0
GetDefaultPrinter and SetDefaulPrinter Problem

I am having a problem with the above features in a vb6 program in Win10.

I am writing a program in which I switch kitchen printers in a a restaurant depending on what has ben ordered (pizza at 1, burgers to another, etc.)

When I try to switch printers using setdefaultprinter and getdefaultprinter these features do not work all the time. MS says there is a problem in previous versions such as win8 but since vb6 in win10 is not supported I am not sure what hotfix, if any, I should use.


The following is the area of the problem. The '<<<< lines are the problem
'This is printing for drinks
Dim oldPrinter As String
Printer.FontBold = True
Printer.FontSize = 14
If NumDrinks > 0 Then
GoSub Headingx
oldPrinter = GetDefaultPrinter '<<<<<<<<<<<<<<
SetDefaultPrinter DrinkOrderPrinter <<<<<<<<<<<<<<<<<<<
Printer.Print sServerName '( 'SERVERNUMBER)
For XXX = 1 To NumDrinks
Printer.Print PrintDrinkItems(XXX)
Next XXX
Printer.EndDoc
End If

'THIS IS FOR APPS ONLY PRINTING
If NumApps > 0 And NumMains = 0 Then
GoSub Headingx
oldPrinter = GetDefaultPrinter '<<<<<<<<<<<<<<<<<<<<<<<
SetDefaultPrinter FoodOrderPrinter '<<<<<<<<<<<<<<<<<<<<<<<<<
For XXX = 1 To NumPrintedItems
Printer.Print PrintItems(XXX)
Next XXX
Printer.EndDoc
End If

Obtaining informations about trapped error

$
0
0
Hi,
When an error is trapped thanks to "on error goto" it is easy to know the error code, line number, ...
When the error is for instance Overflow, Subscript out of range, Type mismatch, Invalid filename, ...
is it also possible to know which variable is involved and its contents ?
Thanks

VS 2015 Saving DataGridView into an Array and then into an Excel Sheet

$
0
0
Hi all,

So what I am trying to accomplish is this:
  1. I open an excel sheet (100 columns and 100 rows as an example) and populate it into a DataGridView control.
  2. Make any changes to the DataGridView information and save the whole thing into an Array.
  3. Use that Array to replace the information that is currently inside the existing worksheet and save.


Step 1: So far, I have opened an Excel sheet into a DataGridView control:
Code:

Dim SheetName As [String] = "Sheet1"
Dim FileType As [String] = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + sPath + ";Extended Properties='Excel 12.0 XML;HDR=YES;';"

Dim con As New OleDbConnection(FileType)
Dim oconn As New OleDbCommand("Select * From [" + SheetName + "$]", con)
con.Open()

Dim sda As New OleDbDataAdapter(oconn)
Dim data As New DataTable()
sda.Fill(data)
DataGridView1.DataSource = data

Step 2: I believe that I have saved any changes into an array (by way of button click):
Code:

Dim array = New Object(DataGridView1.RowCount - 1, DataGridView1.ColumnCount - 1) {}
For Each i As DataGridViewRow In DataGridView1.Rows
    If i.IsNewRow Then
        Continue For
    End If
    For Each j As DataGridViewCell In i.Cells
        array(j.RowIndex, j.ColumnIndex) = j.Value
    Next
Next

Step 3: But from there, I'm not sure what to do. Can anyone help? I have the Array, but no idea how to actually get that Array into the sheet.

Some more information:
I need to get the excel sheet to maintain same formatting (no fancy fonts, or colors, just spacing and cells with multiple lines).

I usually use modern VB .Net, but took a trip down memory lane.

$
0
0
So I started VB with version 3 on Windows 3.1, back in 1993/94. I've gone through every version since, as well as branching out into C, C++, Java, Objective-C, Swift, etc.

Anyway, I installed Win3.1 on VirtualBox, and then installed VB3 in that. It was quite the trip down memory lane. ha ha!

Youtube video of the experience is here.
https://www.youtube.com/watch?v=ejpYHez1JgE

Twitter-Bootstrap 4.0 Login Form

$
0
0
The code requires the following external files:
  • https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css
  • *https://code.jquery.com/jquery-3.2.1.slim.min.js
  • https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js
  • https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js

* - while the slim version is required, the full-blown library would work just as well.

Markup:
HTML Code:

<!-- modal -->
<div class="modal fade" id="frmForgotPassword" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Forgot Password</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <form class="modal-body">
        <div class="form-group">
          <label class="control-label" for="txtForgotEmail">Email Address</label>
          <input class="form-control" id="txtForgotEmail" name="email" type="email" />
        </div>
        <div class="form-group">
          <input class="form-control btn btn-primary" id="btnForgotSubmit" type="submit" value="Reset" />
        </div>
      </form>
    </div>
  </div>
</div>

<!-- main -->
<div class="container-fluid">
  <div class="row justify-content-md-center justify-content-lg-center">
    <form class="col-md-8 col-lg-7 align-self-center mt-5" method="post" role="form">
      <fieldset>
        <legend class="text-center border border-primary border-left-0 border-right-0">Account Login</legend>
        <div class="alert alert-danger alert-dismissible fade show text-center d-none" role="alert">
          <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
          Invalid username and/or password.
        </div>
        <div class="form-group">
          <label class="control-label" for="txtLoginEmail">Email Address</label>
          <input class="form-control" id="txtLoginEmail" name="email" type="email" required="required" />
        </div>
        <div class="form-group">
          <label class="control-label" for="txtLoginPassword">Password</label>
          <input class="form-control" id="txtLoginPassword" name="password" type="password" required="required" />
        </div>
        <div class="form-group">
          <input class="btn btn-lg btn-primary btn-block" id="btnLoginSubmit" type="submit" value="Log In" />
        </div>
      </fieldset>
      <nav class="nav flex-row justify-content-between">
        <a class="nav-link" href="#" data-toggle="modal" data-target="#frmForgotPassword">Forgot Password?</a>
        <a class="nav-link" href="#">Register</a>
      </nav>
    </form>
  </div>
</div>

Fiddle: Live Demo

VS 2017 - Comparing Mulitlined Textboxes and Displaying the Difference in a Listbox

$
0
0
I found this code in the "Thread: [RESOLVED] Compare lines in two textboxes (Multiline)" and it's almost the same to what I am working at which displays the difference of data per line from 2 multilined textboxes and displays the difference in a listbox.
Mine should look like this.

Multiline Textbox1:
a
b
c

Multiline Textbox2:
a
b
c
d

Listbox:
d

I tried modifying the code as follows but I am missing something for it to work correctly:

Code:


        Dim lines1 = txtDatabase.Lines
        Dim lines2 = txtFieldglass.Lines

        For Each line In lines1
            Dim curLine As String = line
            If lines2.Any(Function(s) s.Equals(curLine, StringComparison.CurrentCultureIgnoreCase)) Then
                'line found.
            Else
                'line not found.
                lstFieldglass.Items.Add(curLine)
            End If
        Next

Is there something that I could use that is the opposite of EQUALS for me to be able to modify the code as follows?

Code:


        Dim lines1 = txtDatabase.Lines
        Dim lines2 = txtFieldglass.Lines

        For Each line In lines1
            Dim curLine As String = line
            If lines2.Any(Function(s) s.NotEqual(curLine, StringComparison.CurrentCultureIgnoreCase)) Then
                'line does not exist.
                lstFieldglass.Items.Add(curLine)
            Else
                'line exists.
            End If
        Next

Logging Application Usage

$
0
0
Hi all, first post here so hi to all :wave:

I am currently looking after a legacy application for my current customer who have an old VB6 application built upon a SQL database. The application is long in the tooth and has had multiple additions and changes made to it over the years and as such has many parts which are no longer used by the business and I was wondering if anyone could suggest the best method of identifying this that does not involve the obvious going through the actual business and every user to ask, I was hoping for a more background method that would not interfere with the day to day running.

Now, as for technical details, it is a VB6 as I already mentioned and has a few different applications all connecting to the same database and I have all source code for all applications and can make any necessary code changes to implement any possible solution.

My initial thought is to create a database table that holds a log of all access to each form by creating a method in the base SQL module that all applications use which is then called upon by each form when being loaded. This will record the form, the user opening and the date/time of access. This will give me all I need really initially but I was wondering if there was a way I could 'override' the base Form Load event to do it automagically...:confused:

Also, I would also appreciate any other possible options for achieving this.

I will also need to see if I can come up with a method of doing something similar with the database to see which Stored Procedures are being accessed.

Thanks in advance and apologies if I have missed any information but please just poke me and I will provide anything else you need to know.

Kind regards,
Peter :thumb:

File Locations

$
0
0
I'm always coming in after programs are in place, so I have very little experience when it comes to distribution and installations, especially when it comes to File Locations and Environment Variables and the like.

The web offered up some different opinions / answers as to what and where things belong. As I typically don't get involved with installshield programs, I am looking for how to access and check the existence of files on a system.

Am curious about the proper Environment Variable to use for the following:

Code:

Components                        <system folder>
References                        <system folder>

Program Exe's                        %ProgramFiles%
Private Program Data                %APPDATA%
Common Program Data                %CommonProgramFiles%


Visual Studio VB6.EXE 6.00.9782 CRASH during development

$
0
0
My problem seems similar to: Re: [RESOLVED] VB6 IDE Crashes
I am making and testing modifications to one of my applications within VB6. All too often after I have used some features in a subform and then close it, VB6 crashes.
I am running VB6.exe in a WinXP virtual PC (dedicated to VB6)(VMWare) on my Win7x64 host PC.
Here is the content of the form:
Visual Basic
Visual Basic has encountered a problem and needs to close. We are sorry for the inconvenience.
If you were in the middle of something, the information you were working on might be lost.
Please tell Microsoft about this problem.
We have created an error report that you can send to help us improve Visual Basic. We will treat this report as confidential and anonymous.
To see what data this error report contains, click here.
[Send Error Report] [Don't Send]

New dev - where to begin?

$
0
0
Hi all,

I'm close to finishing up my school where I spend most my time using Java. I recently accepted a position working with Visual Basic.net, ASP.net, and Bootstrap. One of my first projects will be redoing a website using those tools from what I understand. Does anyone have any good recommendations for resources(books, websites, etc) or a good place to start so that I can be as productive as possible on day 1?

EDIT: I've been working on gathering some ASP.net resources but the amount that is out there and with the .net core information available it's a bit overwhelming.

Thank you in advance.

How to get the first word of each line in amultiline textbox?

$
0
0
Hello everyone
I need to know how to get first word of each line in a multiline textbox.
I think the left function doesn't seem to work in a multiline textbox.
Thank you

DPI on Win10

$
0
0
Here's one I wouldn't mind understanding a bit better.
(Also, if you're not on Win10, you're not going to be able to help much with this one. Sorry.)

There's a new GetDpiForMonitor call in the shcore.dll library. (There are actually several other new calls, but I'm focusing on this one.)

Here's some code that I've written that uses it:

Code:


Option Explicit
'
Public Enum MonitorDpiTypeEnum
  MDT_EFFECTIVE_DPI = 0 ' (default) The effective DPI. This value should be used when determining the correct scale factor for scaling UI elements. This incorporates the scale factor set by the user for this specific display.
  MDT_ANGULAR_DPI = ' The angular DPI. This DPI ensures rendering at a compliant angular resolution on the screen. This does not include the scale factor set by the user for this specific display.
  MDT_RAW_DPI = 2      ' The raw DPI. This value is the linear DPI of the screen as measured on the screen itself. Use this value when you want to read the pixel density and not the recommended scaling setting. This does not include the scale factor set by the user for this specific display and is not guaranteed to be a supported DPI value.
End Enum
#If False Then ' Intellisense fix.
    Public MDT_EFFECTIVE_DPI, MDT_ANGULAR_DPI, MDT_RAW_DPI
#End If
'
Private Declare Function GetDpiForMonitor Lib "shcore.dll" (ByVal hMonitor As Long, ByVal dpiType As Long, ByRef dpiX As Long, ByRef dpiY As Long) As Long
'

Public Function MonitorDpiSetting(hMonitor As Long, iDpiType As MonitorDpiTypeEnum) As Long
    '
    ' MDT_EFFECTIVE_DPI:
    '  This is basically the old style DPI.  With Win10, it should really always be 96.  If it's not, someone has been tampering with the bowels of Win10.
    '
    ' MDT_ANGULAR_DPI and/or MDT_RAW_DPI:
    '  These are primarily used for low-level graphics, and are a "virtual" DPI based on the monitor's scale resolution.
    '  Combined with the above, they could be used to determine the actual setting for the scale resolution.
    '
    Dim dpiX As Long
    Dim dpiY As Long
    Dim iRet As Long
    '
    iRet = GetDpiForMonitor(hMonitor, iDpiType, dpiX, dpiY)
    MonitorDpiSetting = dpiX
End Function


Now here's my question. When you execute this on a monitor with scaling set at 100%, MDT_EFFECTIVE_DPI returns 96. This is expected as this is basically to older DPI setting and should stay at 96 for Win10.

When you execute with MDT_ANGULAR_DPI, it returns 93 (scaling still at 100%). And, when you execute with MDT_RAW_DPI, it returns 94 (still 100% scaling).

Why aren't all of these returning 96? Where'd the other pixels go?

Okay, here's some more code that you may need to use the above, to get your monitor handles:

Code:


Option Explicit
'
Private Declare Function MonitorFromWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal dwFlags As Long) As Long
'

Public Function MonitorHandleForHwnd(hWnd As Long) As Long
    Const MONITOR_DEFAULTTONULL = &H0
    MonitorHandleForHwnd = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL)
End Function

If you combine the above, something like the following will report what I'm talking about:

Code:


Private Sub Form_Activate()
    MsgBox MonitorDpiSetting(MonitorHandleForHwnd(Form1.hWnd), MDT_EFFECTIVE_DPI)
    MsgBox MonitorDpiSetting(MonitorHandleForHwnd(Form1.hWnd), MDT_ANGULAR_DPI)
    MsgBox MonitorDpiSetting(MonitorHandleForHwnd(Form1.hWnd), MDT_RAW_DPI)
End Sub

Take Care,
Elroy

[RESOLVED] auto-save user's typing

$
0
0
As I type a lot of text here, I see a yellow label flash "auto-save" periodically. Can I do this on a DevExpress memoedit in Windows my application?

async help for server tcplistener data listener streamsockets

$
0
0
Hi.
At work, we are trying to create a Listening server for Raspberry PI.
I'M running to tons of issues but most of them had to do with async stuff.

Using Windows 10 IoT Core UWP

First Demo
https://www.codeproject.com/Articles...y-Pi-with-Wind

We get everything to work OK but at the end we get an out of memory exception.
The project works and the server is listening but as soon as I send a TCP Client Command -string, then the string is show in the debug window and after that I get a out of range memory exception

Also we get a green line under this:
Code:

public void Run(IBackgroundTaskInstance taskInstance)
{
    ...
 
    var socket = new SocketServer(9000);
    ThreadPool.RunAsync(x => {
        socket.Star();
        socket.OnError += socket_OnError;
        socket.OnDataRecived += Socket_OnDataRecived;
    });
}

Sorry for C# I will be setting this to vb but the demo is in C#.

As at home I do not have the more than vs2012 and no UWP I cannot give the exact green underline for ThreadPool.RunAsync but the explanation is more or less that it cannot run async and will run synchronous. Using IBackgroundTaskInstance to run a backroung app need a lot of async that I rarely use so I'm not sure on what I can replace the ThreadPool.RunAsync with or how to make it run correctly. Again sorry as at home I cannot use any of the examples and I have to go by memory on the problems we got at work.


So the 2 problem here are.
1) What is causing the memory leak
2) If it is the ThreadPool.RunAsync , how can I fix it not to complain (if this seems not to be the problem then ignore and just, if you ca, help for the memory leak)


Second try:

https://windowsinstructed.com/window...server-client/

This is a big tutorial, I don't expect for anyone to read it but the main issue here is this:
I get to the point that I'm opening the port on the main thread with cketManager.DataListener_OpenListenPorts(); (actually I have replaced the main load Mainpage : Page with :

Code:

public sealed class ExampleBackgroundTask : IBackgroundTask
        {
            public void Run(IBackgroundTaskInstance taskInstance)  ...etc

)

The problem here is that we get to the point that the openListenPort is fired and we go to :

Code:

public void DataListener_OpenListenPorts()
        {
            StreamSocketListener DataListener = new StreamSocketListener();
            DataListener.ConnectionReceived += DataListener_ConnectionReceived;
            DataListener.BindServiceNameAsync(ServerPort).AsTask().Wait();
        }

After that I have no idea what event I need to catch when I send a command from the client.

private async void DataListener_ConnectionReceived never fires and the whole application just sits there waiting.

Any idea?

I know this is a large post and requires some effort from someone to answer so I'm not sure that I will get any answers but if someone ever tried to create a Raspberry PI TCP listener and succeed ( as the tutorial are not complete or working, at least on whatever tests we tried) will know the answer.

Anyhow, at least thanks for reading up to here, I appreciate it, even if you don't have an answer.
If you do, even better :)
Thanks

Who is morose?

$
0
0
Roy Moore?
Charlie Rose?

I guess I go with Charlie.
Too bad .. he usually had good guests on his show

What's The Best Option To Kill A Process?

$
0
0
Guy's I know I can terminate a process via WMI Services, TaskKill, CmdLine and API's but what's considered the best option?

The process in question is a PIC Programmer. My program will time the programmer and kill it if it hasn't reported success within a defined timeout period.

The purpose of my program is a safeguard to prevent the programmer from locking up my PC if it encounters an error that its error handlers failed to catch and exit the program.

The Programmer is a Command Line program that's interfaced with a windows GUI for users that don't like to use a console interface but it can be run either way.

Opinions will be appreciated.

Cheers,
Chris

Windows 7 / 10 - VB6 / Access 97 ap fails after new ap installed.

$
0
0
I have a VB6 / Access 97 distributed application. We did not send out any updates for a few years. Recently, we sent out an upgrade for our system. The upgrade is done via InstallBuilder 8.1 Setup.exe file and a WinZip Self Extractor. In order to allow us to use the most recent upgrade of our system on a customer's NEW computer, the Setup.exe will install all of necessary runtime OCX and DLL files.

The VB6 ap is installed on a mixture of Win7 and Win10. The issues occur on both. We have no control over what our customer's computer techs set up and recommend for them as it pertains to Windows / MS Office updates.

At many of our customer's sites, after running the Setup.exe the following problem occurs...

Part of the upgrade process is that when the new version of our VB6 program is started it checks the MDB file (Access 97) for a version number. Since it sees that it is a newer version, it needs to do some updates to the MDB file. It prompts the user to run or not run the update. When it tries to do the update it fails with some MDB error code.

As an interim solution, I simply revert back to the previous version Setup.exe and the user can continue to use the older version with no problems.

I was wondering if anyone else has experienced this type of problem? During my searches / investigation, I found this page identifying an issue with MSCOMCTL.ocx registration. This was caused by one of MS Office updates.
http://www.fmsinc.com/microsoftacces...rols/mscomctl/

SEEKING YOUR WISDOM... I anyone has any knowledge and / or suggestions about how to resolve this problem it would be greatly appreciated.

Many thanks in advance, Wayne.

Other Win7 / Win10 recent issues that we encountered that were not related to our upgrade...

A - One of our customers reported that they could not run the compact and optimize database function (we use the DBEngine CompactDatabase method). It indicated that the "file already in use". They tried rebooting, etc. This error occurred after one of Windows Updates. They told me that they found a solution on the "internet" and had "uninstalled the October update". I am trying to get the specifics from them now. Once they uninstalled the "October update", the compact ran fine.

B - There were 2 separate incidents (2 different customers) where the MDB table record was updated incorrectly. In both cases it was to the same table. Other tables were only partially updated. It looked like it was some malicious code that did this. Based on the "bad data" values that were in those records, there is no way that our VB6 ap could have done that. This same issue occurred on a Win7 computer and (at another customer site) with Win10. Both of them most likely (unknowingly) had Windows Update running while they were running our End-Of-Day Update process. Windows caused the MDB table record to store bad data in a few fields. Of course, neither customer had done a backup for a long, long time. So we had to write a special fix program for each customer to repair the damaged MDB tables. For both sites I suggested that they only allow Windows Update to run at their option.

C - Here are some other serious issues that Windows Update caused in this "PC Talk" forum thread on DPReview.com. Interesting that one of the forum members had friends that worked in MS's QA Testing department that were "sacked" (laid off / terminated).
https://www.dpreview.com/forums/thread/4219057

[RESOLVED] Simple vbs regex q

$
0
0
Hi, new to vbs scripting -- can anyone pleaes let me know how to get the "34" from this string? The numbers will change but the text will always be the same.

Showing 1 to 10 of 34 entries (filtered from 432 total entries)

I assume could just get the characters that are between the 5th blank space and the 6th blank space.

Web Browser Control - FEATURE_BROWSER_EMULATION

$
0
0
i have an active X control that uses the web browser control

I understand i have to set
FEATURE_BROWSER_EMULATION
in the registry in order for it to work "correctly"

but my project is an activeX control and the registry setting is ignored when running in 3rd party applications.

very frustrating.

VS 2013 InvalidCastException - Frustrating

$
0
0
Guys,
You have got to help me out. I wrote this application that connects to an Oracle database, fetches data and uses the data to produce graphs. To the best of my ability, the program works as expected. So, I copied the project to a different location on the same computer and changed the connection string so that the application can connect to a different database. When I try to run this copy of the program, I get InvalidCastException. The master copy still runs without problems.

The line of code that triggers this exception is effectively like the following:
Code:

Dim TypeOfDatabase As string
TypeOfDatabase = "Oracle"  'This value is set according to the type of database the user has chosen.
If TypeOfDatabase.Trim.ToUpper.Equals("ORACLE") Then

When I tried to search for more information about the exception, it says the file 'f:\dd\ndp\clr\src\BCL\system\string.cs' does not exist. The folder path f:\dd\ndp\clr\src\BCL\system does not even exist in my computer. I do not know what is going on. I have been on this the whole day and I am going crazy.

Please, help in any way you can.
Viewing all 42110 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>