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

Need help: Converting centimeter to ft - in

$
0
0
Need help: Converting centimeter to ft - in


I have some basic codes but I can't extract the values in 2 textboxes.

Code:

dim iCM as Double
iCM = 173
Msgbox (FormatNumber(iCM / .0328085, 2))

For example: cm: 173

And result must be like this:
txtFt.text = 5
txtIn.text = 8

Any help?

odd char in RichTextBox etc, display cyrillic chars?

$
0
0
Private Sub Command1_Click()
Dim vocabWordLine As String
Dim TestFile As Integer

TestFile = FreeFile

Open "C:\Users\r\Desktop\vb for word finder thing project\test text fpr splitting2.txt" For Input As #TestFile

Do While Not EOF(TestFile)
Input #TestFile, vocabWordLine
If RichTextBox1.Text = "" Then
RichTextBox1.Text = vocabWordLine
Else
RichTextBox1.Text = RichTextBox1.Text & vbCrLf & vocabWordLine

End If
Loop


This piece of code should load up a .txt or .rtf file, consisting of a number and one word in Russian cyrillic chars per line:

1яблоко


etc...

unfortunately I get ÿþ on my first line, then the number, then unreadable 'I can't read this encoding' stuff:- O1;>:> etc.

Where has ÿþ come from? How can I get rid of it, apart from just using 'replace'?

And how do I get cyrillic chars to display in textboxes, richtextboxes, etc?

I could change the encoding of the source .txt. file, or its format, not sure what to though.

Thanks

Focus

$
0
0
I have created a form to enter IP addresses and am trying to have focus change if the field has a length of 3 of if the period is pressed.

I have tried the with

Private Sub IP1_KeyUp(KeyCode As Integer, Shift As Integer)
If Len(IP1) = 3 Then
IP2.SetFocus

End If
End Sub

I have not tried the other yet.

Thank you for any assist.

David

Where VB6 clobbers Unicode

$
0
0
This is a theme running in about three current threads. I thought I'd just start a thread devoted to it.

My goal is to develop a list of all of the places that VB6 doesn't like Unicode. It certainly seems a discussion worth having. This list is intended to outline where Unicode get clobbered unless special treatment is given.

Here's what I know to put into the list off the top of my head:

  • API Calls
  • Clipboard
  • Strings written to files
  • Assigning control properties that are displayed (.text, .caption, etc)
  • The "IDE Properties Window" (pure ANSI, if I'm not mistaken, and not to be confused with PropertyBag)
  • Using StrConv badly
  • Functions and statements dealing with file names.



Others that come to mind, but I'm not sure (but may test):

SaveSetting/GetSetting (actually not sure, never tried it)

And another that's worth mentioning: The actual IDE code-editor windows. These are also pure ANSI as far as I know, the actual files are also ANSI (.FRM, .BAS, .CLS, .VBP, .CTL)

I know of work-arounds for most of these. The IDE Properties Window is a bit tricky. The only thing I've figured out is to make custom property sheets. Also, it's sad that we can't put unicode literals in our source code files.

I wonder what areas I've missed.

EDIT: Okay, scratch SaveSetting/GetSetting. They seem to work absolutely fine with unicode.

EDIT2: I thought of another place. As far as I know, none of the file name handling functions and statements correctly handle unicode. Specifically Dir$ and Name, and possibly others. I've added it to the bullet-list.

[RESOLVED] Need help: Converting centimeter to ft - in

$
0
0
Need help: Converting centimeter to ft - in


I have some basic codes but I can't extract the values in 2 textboxes.

Code:

dim iCM as Double
iCM = 173
Msgbox (FormatNumber(iCM / .0328085, 2))

For example: cm: 173

And result must be like this:
txtFt.text = 5
txtIn.text = 8

Any help?

Registering ActiveX Controls Automatically

$
0
0
Hey guys, how exactly do you register an OCX automatically when your software opens up? I know how to do it manually using a second piece of software, but can't get it to work automatically within the same software. Thanks for reading.

Nm_click

$
0
0
What is the value of NM_CLICK

I can only find the values of

NM_FIRST
NM_DBLCLK
NM_RETURN
NM_RCLICK

Mathematical Expression to VB Code

$
0
0
Hello
i am new to this forum and i also novice because i had learned VB6
5 years ago and after that i never tried it...
i am trying to building a calculator with manual value data input...
i am posting mathematical formula and please members guide me ho to convert it to VB code

A:=16^^
B:=16^^

SA:=16^^
SB:=16^^

Ex := 16^^10001

AEx := A^Ex
BEx := B^Ex

subSA := AEx - SA
subSB := BEx - SB

Result=BaseForm[GCD[subSA, subSB,], 16]

A,B,SA and SB are input data
at the moment it has 2 values but i could be increased up to 10 values as per usage..

[RESOLVED] Generating Completely Random Number Between A & B ?!

$
0
0
Hello guys ...

I'm using
Code:

Int((A - B + 1) * Rnd) + B
to generate a random number between A and B which are Max and Min values. But there is a question :

How to code the program to generate completely random number each time of running using the code above ?!

Thanks in advance:wave:

point or pset picturebox

$
0
0
hello
i have a project that use PictureBox picPoints with pset.. it takes some coords store them in txt and draw a point in picturebox withthat coords.that i want is to show in picturebox my currrentx-currenty position

[RESOLVED] The Windows (DOS) Environment and the VB6 Environ function

$
0
0
I can't remember the last time I actually used the Windows Environment, possibly back in Basic PDS days, but an issue has come up with respect to what can/can't handle unicode.

I've been looking into the VB6 Environ function and can't get it to work correctly. It works fine for what's in the environment the last time my computer booted, but Environ picks up nothing from changes to the environment I make through a CMD window and use of the SET (DOS) command.

Any ideas on why the VB6 Environ command isn't picking up changes to the environment? Just a bit more info: It doesn't even see new variables added to the environment, and it doesn't see changes made to existing variables.

EDIT: Just a bit more info. I tried reloading the IDE after environment changes, but still no dice. Also, it didn't work either from a compiled VB6 program. This suggests that VB6 is reading some copy of the environment deep in the bowels of Windows, and not the environment you see when a CMD C:>SET command is executed.

VB6: Error 3022 Duplicate Database Key - Again!

$
0
0
I seem to have a real problem with this particular error because it's happening to me again. I'm loading a database with data from a tab delimited file. When the database is empty all goes well.

However, when I run the same file against the database a second time, I expect it to bypass all duplicate records and only add new records from the input file. Instead, it fails on the very first record with the following error:

Quote:

Error: 3022 The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.
The reason I'm running duplicate records against the database is because when I download my source data, there's always duplicates from the day before. So I need to detect and bypass them to maintain my data integrity. But for some reason it's not recognizing the duplicates. Here's the code I'm running:

Code:

Option Explicit

Public Sub SalesProcessing()

'--------------------------------------------------------------------------------'
' The purpose of this submodule is to import sales records into the MDB that
' are downloaded from Amazon and then recover the physical shelf space of sold
' merchandise so it can be reused.
'--------------------------------------------------------------------------------'

    On Error GoTo ErrorRoutine

'--------------------------------------------------------------------------------'
' Database Declarations
'--------------------------------------------------------------------------------'

    Dim rsOrderRec              As DAO.Recordset

'--------------------------------------------------------------------------------'
' Global Declarations And Initializations
'--------------------------------------------------------------------------------'

    gStrGeneralVariable = ""

'--------------------------------------------------------------------------------'
' Input File Declarations
'--------------------------------------------------------------------------------'

    Dim dblInFile              As Double

'--------------------------------------------------------------------------------'
' Local Declarations And Initializations
'--------------------------------------------------------------------------------'

    Dim bSpaceRecovered        As Boolean      ' Required to call the shelf space recovery module

    Dim intMsgAnswer            As Integer      ' Determines which msg to display when processing is complete

    Dim I                      As Long        ' Loop index
    Dim lngMaxArray            As Long        ' Array subscript range
    Dim lngDupCtr              As Long        ' Counts the # of dup records skipped
    Dim lngTotalRecords        As Long        ' Counts the total # of records processed
    Dim lngRecCounter          As Long        ' Counts the # of records processed
   
    Dim strInput1              As String      ' Holds the input filename
    Dim strInputPurchaseDate    As String      ' Holds the purchase date of the sale
    Dim strInputItemStatus      As String      ' Tells if the item is shipped or unshipped
    Dim strInputOrderStatus    As String      ' Tells if the order is shipped, unshipped, or cancelled
    Dim strInputAmazonOrderId  As String      ' Order # supplied by Amazon
    Dim strInputAsin            As String      ' Product identifier supplied by Amazon
    Dim strSalesDataFile        As String      ' File level data string
    Dim arrFileLines()          As String      ' Record level array elements
    Dim arrDailySales()        As String      ' Field level array elements

    lngRecCounter = 0
    lngMaxArray = 0
    lngDupCtr = 0
    lngTotalRecords = 0
    intMsgAnswer = 0

'--------------------------------------------------------------------------------'
' Procedure Division
'--------------------------------------------------------------------------------'

    dblInFile = FreeFile                                            '<- Get next available file number
    strInput1 = App.Path & "\Orders"                                '<- Format directory path to where the data resides
    ChDir strInput1                                                '<- Change directory
    strInput1 = Dir("*.txt")                                        '<- Select only txt files or change to any extension

    If strInput1 & vbNullString = vbNullString Then                                          '<- Check if filename input box is empty (meaning there are no input files to process)
        intMsgAnswer = 1                                            '<- The input file is missing
    Else
        Set dbMdbRec = OpenDatabase(App.Path & "\" & "MASTER.MDB")
        Set rsOrderRec = dbMdbRec.OpenRecordset("ORDERS ", dbOpenTable)
        rsOrderRec.Index = "PrimaryKey"

        Do While strInput1 <> Empty                                '<- Loop through directory folder
            intMsgAnswer = 0                                        '<- We're good to go
            Open strInput1 For Input As #dblInFile                  '<- Prep input file
            If LOF(dblInFile) > 0 Then                              '<- Check for empty file
                Line Input #dblInFile, strSalesDataFile            '<- Read the whole file into a string
                arrFileLines = Split(strSalesDataFile, Chr$(10))    '<- Split the string into records and store them in an array
                lngMaxArray = UBound(arrFileLines) - 1              '<- Set the array max limit
                For I = 1 To lngMaxArray                            '<- Access each record, skipping 0 which is the header
                    arrDailySales = Split(arrFileLines(I), Chr$(9))    '<- Split each record into fields
                    strInputAmazonOrderId = Trim(CStr(arrDailySales(0))) '<- Grab 1 of 5 primary key fields
                    strInputPurchaseDate = Trim(CStr(arrDailySales(2)))  '<- Grab 2 of 5 primary key fields
                    strInputOrderStatus = Trim(CStr(arrDailySales(4)))  '<- Grab 3 of 5 primary key fields
                    strInputAsin = Trim(CStr(arrDailySales(12)))        '<- Grab 4 of 5 primary key fields
                    strInputItemStatus = Trim(CStr(arrDailySales(13)))  '<- Grab 5 of 5 primary key fields

                    With rsOrderRec
                        .Index = "PrimaryKey"
                        .Seek "=", CStr(strInputAmazonOrderId), CStr(strInputPurchaseDate), CStr(strInputOrderStatus), CStr(strInputAsin), CStr(strInputItemStatus)
                        If .NoMatch Then
                          'DEBUG STATEMENT SHOWS THE PRIMARY KEYS OF FAILING RECORD
                            Debug.Print "No match: " & CStr(strInputAmazonOrderId) & " " & CStr(strInputPurchaseDate) & " " & CStr(strInputOrderStatus) & " " & CStr(strInputAsin) & " " & CStr(strInputItemStatus)

                            rsOrderRec.AddNew
                                rsOrderRec![AMAZON_ORDER_ID] = Trim(CStr(arrDailySales(0)))
                                rsOrderRec![MERCHANT_ORDER_ID] = Trim(CStr(arrDailySales(1)))
                                rsOrderRec![PURCHASE_DATE] = Trim(CStr(arrDailySales(2)))
                                rsOrderRec![LAST_UPDATED_DATE] = Trim(CStr(arrDailySales(3)))
                                rsOrderRec![ORDER_STATUS] = Trim(CStr(arrDailySales(4)))
                                rsOrderRec![FULFILLMENT_CHANNEL] = Trim(CStr(arrDailySales(5)))
                                rsOrderRec![SALES_CAHNNEL] = Trim(CStr(arrDailySales(6)))
                                rsOrderRec![ORDER_CHANNEL] = Trim(CStr(arrDailySales(7)))
                                rsOrderRec![URL] = Trim(CStr(arrDailySales(8)))
                                rsOrderRec![SHIP_SERVICE_LEVEL] = Trim(CStr(arrDailySales(9)))
                                rsOrderRec![PRODUCT_NAME] = Left(arrDailySales(10), 255)
                                rsOrderRec![SKU] = Trim(CStr(arrDailySales(11)))
                                rsOrderRec![ASIN] = Trim(CStr(arrDailySales(12)))
                                rsOrderRec![ITEM_STATUS] = Trim(CStr(arrDailySales(13)))
                                rsOrderRec![QUANTITY] = Trim(CStr(arrDailySales(14)))
                                rsOrderRec![Currency] = Trim(CStr(arrDailySales(15)))
                                rsOrderRec![ITEM_PRICE] = Trim(CStr(arrDailySales(16)))
                                rsOrderRec![ITEM_TAX] = Trim(CStr(arrDailySales(17)))
                                rsOrderRec![SHIPPING_PRICE] = Trim(CStr(arrDailySales(18)))
                                rsOrderRec![SHIPPING_TAX] = Trim(CStr(arrDailySales(19)))
                                rsOrderRec![GIFT_WRAP_PRICE] = Trim(CStr(arrDailySales(20)))
                                rsOrderRec![GIFT_WRAP_TAX] = Trim(CStr(arrDailySales(21)))
                                rsOrderRec![ITEM_PROMOTION_DISCOUNT] = Trim(CStr(arrDailySales(22)))
                                rsOrderRec![SHIP_PROMOTION_DISCOUNT] = Trim(CStr(arrDailySales(23)))
                                rsOrderRec![SHIP_CITY] = Trim(CStr(arrDailySales(24)))
                                rsOrderRec![SHIP_STATE] = Trim(CStr(arrDailySales(25)))
                                rsOrderRec![SHIP_POSTAL_CODE] = Trim(CStr(arrDailySales(26)))
                                rsOrderRec![SHIP_COUNTRY] = Trim(CStr(arrDailySales(27)))
                                rsOrderRec![PROMOTION_IDS] = Trim(CStr(arrDailySales(28)))
                            rsOrderRec.Update '<- CODE FAILS HERE
                            lngRecCounter = lngRecCounter + 1                  '<- Count successfully processed records
                        Else
                            lngDupCtr = lngDupCtr + 1  '<- Count skipped records
                        End If
                    End With
                Next                            '<- Read the next record
            Else
                intMsgAnswer = 2                '<- The input file is empty
            End If
            Close dblInFile                    '<- We're done with this file
            strInput1 = Dir()                  '<- Get the next input file
        Loop                                    '<- End of loop that reads folder txt files
        rsOrderRec.Close
        Set rsOrderRec = Nothing

        Erase arrDailySales
        Erase arrFileLines

        lngTotalRecords = lngDupCtr + lngRecCounter  '<- Tally the total # of records processed

    End If

    Select Case intMsgAnswer                    '<- Display an end of processing message
        Case 0
            MsgBox Format(lngRecCounter, "##,###,##0") & " new transactions were added to the ORDERS table." & _
                vbNewLine & Format(lngDupCtr, "##,###,##0") & " duplicate records were skipped." & _
                vbNewLine & Format(lngTotalRecords, "##,###,##0") & " total records were processed.", vbOKOnly
        Case 1
            MsgBox ("There is no ORDERS input file to process"), vbOKOnly
        Case 2
            MsgBox ("The ORDERS input file is empty"), vbOKOnly
    End Select

Exit Sub

ErrorRoutine:
    If Err.Number > 0 Then
        gIntErrNum = Err.Number
        gStrErrDesc = Err.Description
        Call ErrRtn
    End If

End Sub

I'm attaching some sample data for anyone interested. Can some one point me in the right direction?
Attached Files

Webbrowser control - how to get data from html table cell/col item, that is clicked?

$
0
0
Hello,

i have problem with webbrowser control - how to detect which item is clicked in html table cell/col and get the clicked cell data?

Seems that there is no ItemFromPoint functionality as is in .Net version.

Unfortunately this is large VB6 project, not feasible to convert .net - so hence need to develop further in VB6.

Attached is small project, in there is three row/col table.

HTML document object model is quite large and didn't able to recognize proper methods/properties for task in hand.

So asking, if someone knows;
What object(s) etc. i need to reference (in html document object) to detect which cell is clicked and then extract cell data to VB variable?
Attached Files

[RESOLVED] Center picturebox on a grid

$
0
0
I have a form which contains a mshflexgrid and I would like to center a small picturebox over that grid.

It's been a long time since I needed to do something like this and my old brain can't come up with the formula. Can you help?

Can't compile my apps after upgrading to Windows 10

$
0
0
I have Googled this to death and nothing, so here is the current setup:

Upgraded development machine from Win 7 Pro to Windows 10. No problem.
After upgrade finished, loaded a project into vb6 then started with full compile. No problem and app runs perfectly in development environment as expected.
I thought I was home and dry.

Background:
VB6 was, and still is set to run in compatibility mode for WinXP service pack 3 and "as administrator" - nothing was changed for, or during, the upgrade.
VB6 and CR11 was working and compiling faultlessly with Win 7 Pro before the upgrade.

The problem:
When I attempt to compile to .EXE then VB6 compiles OK up to a point - the shows System Error &H80004005 !!!
Obviously you are not shown where in the code this error occurred - just an OK button and when clicked it stops creating the .EXE file.
So nice...I can't create a an .EXE now! Thank you Microsoft.

Like I said, Googled this silly and nothing.
Now I'm sure I'm not the only VB6 developer who has run into this.
Anybody out there with a solution, workaround or fix?

Picture Encryption and Decryption ?!!!

$
0
0
Hi dear programmers.

This is my first post here and to tell you the truth I'm not quite sure whether it is a right location to post such a question :ehh:

Anyhow , I want to encrypt .jpg format in order to unable unwanted visitors (!) to open and take a look at them! IS there any way to encrypt and decrypt the .jpg pictures with program and coding ?

** I'm have been working on visual basic6 and recently on visual studio 2013.
** I don't want to hide picture (u know why:))

I would appreciate helpful guidance , and THANKS

[RESOLVED] All Of My Project Files Are Missing From My VS6 IDE

$
0
0
I think I seriously damaged my project. When I try to open my project in Visual Studio, the Project Explorer window is empty, except for the name of the project itself. All of my forms and modules are gone! :eek:

When I look at the physical directory, they're all there. But for some reason, VS6 can't see them.


Here's what my project explorer looks like:

Project Explorer Empty.doc

These are the files the project should contain:

Missing Files.doc

Is there a way I can restore those reference pointers?:confused:
Attached Files

Dim aa, bb, cc As Double? Acceptable?

$
0
0
Is it acceptable to put them all on 1 line like the following?

Dim aa, bb, cc As Double

or better to list seperatly

Dim aa As Double
Dim bb As Double
Dim cc As Double

I've put them on 1 line in the past and no problems, but with the app i'm working on, it's crashing unless they are seperate.

RTB Fromatting

$
0
0
I have a RichTextBox that is formatted with colors, fonts, underlines and more. What I would like to do is insert text into the RTB that's already formatted.

Currently the code adds a single word to the RTB, then using SelStart, SelLength and so on it modifies the attributes of the text which is very slow. But if I could format the entire length of text being inserted beforehand then it could be added to the RTB all at once.

Adding to the RTB word at a time is very slow compared to loading complete sentences or paragraphs. And this slow-down seems to grow exponentially based on the size of the RTB.

The only problem is that I have no idea how if even possible to format a VB string that's compatible with a RTB.

Thanks.

VB6 on Win7

$
0
0
I'm attempting to install VB6 on a Windows 7 Pro machine and I need some guidance. I ran the setup as administrator, acknowledged the "known compatibility issues", and it seems to have installed successfully.

When I load an existing project, I get error messages relating to the registry. There are also some lib files that it complains are not registered.

I know some of you guys run Win7 with VB6, so what do I need to do?

Thanks
Viewing all 21089 articles
Browse latest View live


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