Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all 21859 articles
Browse latest View live

[RESOLVED] Remove dupes from two listboxes

$
0
0
Hi everyone,

First of all, I do not know if this is possible or if there is a code for this task, but,
searching on the forum I found that removing dupes from listbox has been asked hundreds of time.
But in my case what I really need is a way of finding text on the two listboxes and then if listbox1
have one or two dupes then, remove them. I know how to do this but an a single listbox.

VB6 CDO problem

$
0
0
I have a program which uses CDO to send an email over smtp.gmail.com:587. Yesterday it was working fine, but today it is getting hung up on the line MailMsg.Send. None of my server settings have changed, and the logon credentials are still the same too.

Here are the relevant bits of code:
Code:

    Dim MailMsg As New CDO.Message
    Dim MailCfg As New CDO.Configuration

...

    MailCfg.Fields.Item(cdoSMTPAuthenticate) = cdoBasic
    MailCfg.Fields.Item(cdoSendUserName) = txtEmail.Text
    MailCfg.Fields.Item(cdoSendPassword) = txtPassword.Text
    MailCfg.Fields.Item(cdoSMTPUseSSL) = True
    MailCfg.Fields.Item(cdoSMTPServerPort) = 587 '465
    MailCfg.Fields.Item(cdoSendUsingMethod).Value = 2
    MailCfg.Fields.Item(cdoSMTPServer).Value = txtServer.Text
    MailCfg.Fields.Item(cdoSMTPConnectionTimeout) = 30
    MailCfg.Fields.Update
    MailMsg.Configuration = MailCfg

...

    MailMsg.To = txtEmailTo.Text
    MailMsg.From = txtEmailFrom.Text
    MailMsg.Subject = txtSubject.Text
    MailMsg.TextBody = txtBody.Text
    lblStatus.Caption = "Attempting to send email"
    MailMsg.Send
    lblStatus.Caption = "Email sent"

There is no "On Error Resume Next" anywhere in the code, and I am receiving no error messages. lblStatus.Caption is set to "Attempting to send email", but never makes it to "Email sent", and no email is ever delivered. Any ideas what could be causing this issue?

Thanks in advance,
BurritoBandito

RegEx with lookahead, lookbehind and capturing groups

$
0
0
I've read somewhere that "Microsoft VBScript Regular Expressions 5.5" library doesn't support lookahead, lookbehind and capturing groups because it's outdated. Is this true? If it is, then I'm looking for replacement like a (class) module because I don't want to deal with external components (DLLs).
I see that Regexes with things that are mentioned in the title don't work. For example, this. Where is a problem if the library fully supports RegEx?

Error 5 on Something so Simple

$
0
0
Hi all.

Does anyone know why this simple task will not work? When I try to do this simple operation:
Code:

Dim A as Double
Dim NewA as Double
Dim Abby as Double

A= -502.14
Abby = 0.5
NewA = A ^ Abby

It fails at the last line with Error 5 (Invalid Procedure Call or Argument)


Yet in the Immediate Window I can enter the values of the variables and all is fine:
Code:

?-502.14^.5
-22.4084805375108

Or even this works:
Code:

? -502.14^Abby
-22.4084805375108

But not this:
Code:

? A^Abby
What am I missing here? I'll bet it's something really stupid.

[RESOLVED] type mismatch on addition

$
0
0
I have this msflexgrid. For example I have this column0 and column1. I multiply column0 value and column1 and put the result on column2. Then I have this function below to sum up the rows of column2 to get the over all total.

Code:

Private Function SumColumn (columnNum as integer)
        Dim temp
        temp = 0
        For i = 1 To myfg.Rows - 1
            temp = temp + (myfg.TextMatrix(i, columnNum))
        Next i
       
        SumColumn = temp
End Function

I did not indicate the data type of the function cause I am not sure what to use.

So when I use this function with error trap, I got type mismatch error. but I remove the error trap, it will work just fine but i would like to know what should be done so that I wont have type mismatch error even if I have error trap.

SHELL execute via code

$
0
0
i need to assign to click botton this code line, and execute it:

"C:\Program Files\Microsoft Office\Office14\MSAccess.exe" "\\rom\workarea$\FSR\Ge\DATABASE\T1.MDB" /compact

how to?
Tks.

[RESOLVED] Reading Numbers from text file

$
0
0
Hi Everyone.
I have an old VB6 application that I wrote several years ago, and works fine for me, so I want to continue using it. I am using the program to read an external text file that contains prices and qty of various stocks. Previously, the numbers came without a thousands separator, so it was simple to read them. eg, 1000, 5000 etc. But recently, the file provider has changed the format and now uses a comma as a thousand separator. So a quantity of 1000 is written as 1,000. I wrote the following code to read the file, and because of the comma, my code reads a quantity of 1,000 as 1 only.
Any idea on how to adjust this?

asTr(6) is the quantity. If the quantity is 500, I can read it fine...but if its 1,000, it is read as 1.

Code:

Open App.Path & "\marketfeed-" & Format$(Now, "dd-mm-yyyy") & ".msg" For Input As SourceNum

  Do While Not EOF(SourceNum)
            Line Input #SourceNum, Data
            y = 1
           
        aStr = Split(Data, " ")
               
     
          If aStr(1) = "Symbol" Then
            Value = Val(aStr(6))
          End If
             
          Loop
  Close #SourceNum

VB6 application setup installation debugging

$
0
0
All,

Our client have a VB application which has reporting stuff(crystal reports 8.5). The project is compiling and we were able to create setup file using VB Package and Deployment wizard(the dev code is in Vista 32 bit OS). We given the setup to testing team who has Win 7(64 bit). When they run the setup, it goes to 100% and just hangs with information "Updating System Please wait".

Not sure whetehr we have any option to enable debugging/log information of the installation events so that we can identify the issues.

Can anyone throw some light to identify the issue?

Thanks

Guhan

data type question

$
0
0
I know that NULL has no data type however I have this function like so

Code:

Option Explicit
Private Function LongValueOrNull(ByVal myvalue as long)                   
    If myvalue = "" Then
        LongValueOrNull= Null
    Else
        LongValueOrNull= myvalue
    End If
End Function

Since there is a return value to NULL, so I am not sure if I should set that to Variant Type but myvalue is set to Long so supposedly it should be long.

Moreover, myvalue might not be long data type always. It might be a decimal or currency. If I will create different functions for different data types then it would be so many functions.

Deploy unique file to common PDW package wihtout running PDW every time

$
0
0
I have an VB6 application that requires a unique file for each deployment, however, do not want to re-run the PDW for the application every deployment just to include the unique file. Is there another way to simply copy the unique file to the PDW directory that has the .LST file to then modify the .LST file to copy the unique file in the .LST directory (not in the .CAB) to the ($AppPath) location? Suggestions appreciated.

msstdfmt.dll out of date message running PDW

$
0
0
Ran the latest run time file updates that were available for XP and VB6 SP6 but still get the msstdfmt.dll out of date message. Is there an easy way to install the latest msstdfmt.dll or is it time to move on from VB6 to the current platform? (Recommendations for transition appreciated, VB.NET? I hear VB6 -> VB.NET translators exixt....) Thanks.

VB6 Freezes When Saving Files

$
0
0
Hi All,

I am running VB6 on Windows 8.1. Whenever I try to do any type of "save" or "save as" operation within the VB6 interface, it freezes (locks up) my PC and many times Task Manager will not open afterwards (it "hangs" as well). If I add a new form to a project and try to "save as", it freezes. If I try to add an icon to a form, it freezes. If I try to open a common dialog control within the VB6 interface, it freezes (the common dialog seems to work fine in the .exe).

This is driving me crazy and I'm somewhat at a loss as to how to resolve this. Any help/suggestions would be greatly appreciated!!

Larry

[RESOLVED] trying to get the lastlogin Via Top 1 * Shows Current Login

$
0
0
when i enter the system i am trying to get the last login of a user but some how
it shows me the current login why?
this is my code
Code:

Dim RsLogin As New ADODB.Recordset
RsLogin.Open "Select Top 1 * From HistoryLogs Where LogName = '" & UsLogin & "'ORDER BY LogId desc", CN
    If Not RsLogin.EOF Then .... So ON So ON

Code:

Table -HistoryLogs
LogId number
LogDate Date/Time
LogName Text
LogIn Date/Time

now before i see this msg i insert to the HistoryLogs this
Code:

ULog = NextID("LogID", "HistoryLogs")
 CN.Execute "INSERT INTO HistoryLogs (LogID, LogDate, LogDay, LogName, LogIn) VALUES (" & _
 ULog & ", #" & Format(Now, "mm/dd/yyyy") & "#,'" & Format(Date, "dddd") & "','" & UsLogin & "', #" & _
 Format(Now, "HH:MM:SS") & "#)"

is there a way to get the before record?
i mean
E.x
if i loged at 15:43
and then loged at 18:33
so i need to see in the msg LastLogin 15:43
tnx for any help
salsa31

[RESOLVED] Updating an ADODB record syntax, I'm very close, but missing something.

$
0
0
I have no errors with this simple code, but it doesn't write the updated field values.
What am I overlooking? I'm moving everything in this project from DAO to ADO, this is my first save edited record procedure.

Code:

Dim iSQLStr As String
Dim rsCon As ADODB.Recordset
Set cnCon = New ADODB.Connection
Set rsCon = New ADODB.Recordset
cnCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                        "Data Source=" & GetDataPath
cnCon.Open
  iSQLStr = "SELECT * FROM tblData WHERE patID = '" & cmbID.Text & "' & AND Num = '" & cmbpatNum.Text & "'"
  rsCon.Open iSQLStr, cnCon, adOpenStatic, adLockOptimistic, adCmdText
    rsCon.Fields("Group").Value = cmbGroup.Text
    rsCon.Fields("Label").Value = txtLabel.Text
    rsCon.Fields("Floor").Value = cmbFloor.Text
    rsCon.Fields("Wing").Value = cmbWing.Text
    rsCon.Fields("Mess").Value = cmbMess.Text
    rsCon.Fields("Trans").Value = cmbTrans.Text
  rsCon.Update
MsgBox "Record Successfully updated", vbInformation
cnCon.Close

Any advice greatly appreciated

Mouse Hooking Outside Area

$
0
0
I have done a couple of different ways to get the position of the mouse above the form to know when its hovering something.
when i create a project i usually like to skip the need of a commandbutton or textbox or whatever, i usually use GDI to create everything. that means i need to know everything, where the mouse is, if the mousebutton is pressed, released, if outside the form or inside a picturebox/frame/component.

the latest code im using to do that is with hooking, CallWindowProc, some code:

Code:

Public Function WindowProcForm(ByVal lWnd As Long, ByVal lMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    HookMsg lMsg, Val(lParam And 65535), Val(lParam / 65536), 1, wParam
    WindowProcForm = CallWindowProc(ProcForm, lWnd, lMsg, wParam, lParam)
End Function

im calling another function/sub because there could be multiple hooking.
all the hooks calls the same function/sub, here how it looks:
Code:

Sub HookMsg(ByVal Msg As Long, ByVal x As Long, ByVal y As Long, ByVal dc As Long, Optional w As Long)
that will give me the Msg, x & y coordination, dc is used if multiple hooking and w if theres a need of the wParam.
everything works great. but theres one thing that i can't get using hooking so im forced to use a timer. i don't like that.
here code of the timer:
Code:

Call GetCursorPos(MousePoint)
ObjHwnd = WindowFromPoint(MousePoint.x, MousePoint.y)
If ObjHwnd <> FieldHwnd Then HookMsg 133, MousePoint.x, MousePoint.y, 1 + FormNumber

that will trigger when the mouse goes outside the hooked area.
im calling the same HookMsg here with the "Msg=133", the 1 + FormNumber is because im using 2 forms with different hwnd.

so my question is, do you know a way to do this without using a timer?
my other "ways" are using a timer, so i know how to do that but i like the idea of a hook method.

CTRL+A, CTRL+E issues with VB6 App

$
0
0
Hello,
I am trying to add shortcuts to a keyboard app I created, and am encountering issues with two key combinations: CTRL+A and CTRL + E. When I do the following code, the CTRL+A inserts, but also highlights the text (an accented a), and the CTRL+E inserts, but also centers the text (an accented e).

Code:

      'á
      If (KeyCode = vbKeyA) And (Shift = vbCtrlMask) Then
      Clipboard.SetText "á"
    Text2.SelText = Clipboard.GetText
    Text2.SetFocus


      'é
      If (KeyCode = vbKeyE) And (Shift = vbCtrlMask) Then
Clipboard.Clear
Clipboard.SetText "é"
Text2.SelText = Clipboard.GetText
Text2.SetFocus
End Sub


Are these key combinations already being used by VB by default? Is there a way to disable the default behavior and force the behavior I need, which is simply to insert the accented letters at the cursor position? The code above works fine when you place it into a button_click event, e.g.

Code:

Private Sub Command14_Click()
Clipboard.Clear
Clipboard.SetText "é"


Text2.SelText = Clipboard.GetText
Text2.SetFocus
End Sub

Any insight would be appreciated. Thank you!

In case you need to convert between pixels and himetrics

$
0
0
When using picture1.image.width I noticed an unfortunate thing, the units aren't pixels. Instead they are called himetrics. So I made a really big picture box (pixelwidth = 0x8000) and then did picture1.image.width/picture1.scalewidth (with the scale mode set to pixels). This gave me the number of himetrics per pixel.

The below constants are a Double and a Single (rounded from the double version, via CSng), which are the conversion factor.
Code:

Private Const HimPerPix As Double = 26.4583409631936
Private Const HimPerPixS As Single = 26.45834

Multiply pixels by the factor to get himetrics, or divide himetrics by the factor to get pixels. If the result of the multiplication or division has a decimal, round to the nearest integer to get the same value as would be returned by the program when queried directly. All 8 of the below lines of code, using the above 2 constants, should always return true.
Code:

Picture1.ScaleWidth=CLng(Picture1.Image.Width/HimPerPix)
Picture1.ScaleWidth=CLng(Picture1.Image.Width/HimPerPixS)
Picture1.ScaleHeight=CLng(Picture1.Image.Height/HimPerPix)
Picture1.ScaleHeight=CLng(Picture1.Image.Height/HimPerPixS)
Picture1.Image.Width=CLng(Picture1.ScaleWidth*HimPerPix)
Picture1.Image.Width=CLng(Picture1.ScaleWidth*HimPerPixS)
Picture1.Image.Height=CLng(Picture1.ScaleHeight*HimPerPix)
Picture1.Image.Height=CLng(Picture1.ScaleHeight*HimPerPixS)

Send Email from VB6 with Outlook 64 bits

$
0
0
Hi

My application works perfectly with all version of Outlook 32 bits, to send emails.

It send email with attachments.

But of course, it doesn't work with outlook 64 bits.

Do you have any idea on how make it work with Outlook 64 bits?

With outlook 32, I use this code :
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(0)
etc...

I don't want to force the user to use his SMTP configuration, as he would like to see the emails sent in the sent items.

I could eventually use
Declare Function MAPISendMail Lib "MAPI32.DLL" Alias "BMAPISendMail" (ByVal session&, ByVal UIParam&, message As MAPIMessage, Recipient() As MapiRecip, File() As MapiFile, ByVal Flags&, ByVal reserved&) As Long

But no outlook 64 bits to test.

According MS : https://msdn.microsoft.com/fr-fr/lib...ice.14%29.aspx
It should work
Any idea, or this MapiSendMail will work with outlook 64?

Thanks in advance.

Running VB6 and VC++6 in windows 8/8.1

$
0
0
Hi,

I've tryed to install both VB6 and VC++6 in my laptop, which runs Windows 8.1. Not a very good experience...

Apparently, these softwares are not suported by the newest versions of windows.
Compatibility issues...

Either way, there's a solution - and I thought I might share it here for who wants to run these version in this "hell" OS...

Regarding VB6, just install it normally but as an administrator (despite the warnings of compatibility ) except for the Data access option ( make a custom install, and de-select this option). After reboot, it would probably run, but a final step must be done: to install VB6 service pack 6. As we are going to see in VC++ 6, install Service Pack 6 for Visual Basic 6.0, Visual C++ 6.0 with Visual Source Safe 6.0d (extract files, and run setupsp6.exe).

In VC++6, you can install all the setup version, except don't register the environment variables. Run as an administrator as well.

After the setup has finished, uncompress the file VS6sp61.cab in service pack 6; copy all the files from the generated folder VS6sp61\Common\msdev98\bin (including the subdir IDE) to your Visual Studio folder (the one with VB6 and VC++6 - something like c:\programs x86\Microsoft Visual Studio\COMMON\MSDev98) - replace all the existing.

To run VC++ 6, make a shortcut to the file in the bin folder called msdevP.exe (if it doesn't work - but it will - try msdevS.exe)

In the process, you might receive an annoying notification that the installer can't delete a vssetup.ttf file... just ignore it as many times it takes - the setup will go on.

That's it :) Good luck!

Kind regards,

JKepler

VB6 will run without problems - believe me.

paper size question

$
0
0
I am using crystal report 10 with code crxReport.PaperSize. There are values that you can choose but I want to create my own crystal report paper size.

What I would like to achieve is I can use the paper size that I added on the print server properties on my crystal report code
like crxReport.PaperSize = CustomerHalfPaper.

How can I do that ?
Viewing all 21859 articles
Browse latest View live


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