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

[RESOLVED] copying project folder to other drives

$
0
0
I would like to move/copy some of my project folders to another drive (local). When I do this and open up that proj (on that drive) VB6 doesnt see all the forms in that newly created folder

What I get is a path error telling me that those forms do not exist. This there a elegant way of using project files on those drives without re-saving those forms and other pieces of the proj individually?

VB6 Inet Put file not loaded

$
0
0
Hi !
I upload files to my server with this code
Code:

On Error GoTo InetError
Inet.URL = "ftp://ftp.rudyv.be"
Inet.UserName = "xxxxxx"
Inet.Password = "******"
Inet.Execute , "PUT " & Source & " /" & Destination
While Inet.StillExecuting
    DoEvents
    Sleep 1000 '1sec
    DoEvents
Wend
Inet.Execute , "CLOSE"
While Inet.StillExecuting
    DoEvents
    Sleep 1000 '1sec
    DoEvents
Wend
On Error GoTo 0
Exit Sub

InetError:
MsgBox ("Error : " & Err.Number & " (" & Err.Description & ")" & Inet.ResponseCode & ":" & Inet.ResponseInfo), vbExclamation
On Error GoTo 0
Exit Sub

Most of the time this works fine, the Source file is uploaded to Destination.
The problem is that some time it does not work but I don't get any trapped error, simply the file is not uploaded and I don't know why.
An idea ?

Move form to center and bottom of screen/desktop

$
0
0
I have a vb form simple and basic with one label text. I want to move that form to the center and bottom of the screen/desktop. How to do that with vb6?

Result Set .Fields(#) is Null... causing code to error out (trouble catching)

$
0
0
As many of you, I have also inherited some VB6 code. The original line of code was:
lUnits = .Fields(10)

But, I am getting a debug error saying Invalid use of Null. When I hover the line, it clearly indicates that .Fields(10) is Null. I tried to catch the Null value with:

Code:

If .Fields(10) Is Null Then
  lUnits = 0
Else
  lUnits = .Fields(10)
End If

When I run the code, the If statement does not catch the Null value. Still jumps to the ELSE line (and still errors on Invalid use of Null). I also tried "is Nothing" with the same result.

I am not sure how to catch the Null value with VB??

Error while displaying data from SQL

$
0
0
I try to show several data in my table, I used INNER JOIN to display the data.. here's my code to display those data (works in SQLYog)

Code:

SELECT mahasiswa.NPM, mahasiswa.NamaMhs, mahasiswa.Jurusan,
mahasiswa.grup,mahasiswa.ta, bayar_lab.persen, bayar_dpp.persen
FROM bayar_dpp INNER JOIN bayar_lab ON bayar_dpp.NPM = bayar_lab.NPM
INNER JOIN mahasiswa ON bayar_lab.NPM = mahasiswa.NPM ORDER BY mahasiswa.NPM

And here's my code on VB6 that will show these data on a VSFlexGrid
NOTE : "TampilGrid" function is to execute the Query I made

Code:

Private Sub TampilGrid(ByVal SQLnya As String)
    Grid.Rows = 1

    Call AksesRS(SQLnya)
    While Not rs.EOF
        Grid.Rows = Grid.Rows + 1

        Grid.TextMatrix(Grid.Rows - 1, 0) = rs.Fields(0)
        Grid.TextMatrix(Grid.Rows - 1, 1) = rs.Fields(1)
        Grid.TextMatrix(Grid.Rows - 1, 2) = rs.Fields(2)
        Grid.TextMatrix(Grid.Rows - 1, 3) = rs.Fields(3)
        Grid.TextMatrix(Grid.Rows - 1, 4) = rs.Fields(4)

        lb_persendpp.Caption = Val(rs.Fields(5))
        lb_persenlab.Caption = Val(rs.Fields(6))
        rs.MoveNext
    Wend
End Sub

But an error occurred.. It shows

Quote:

Item cannot be found in the collection corresponding to the requested name or ordinal
Can you tell me what's wrong?

Thanks

ActiveX OCX on 64-bit Office

$
0
0
Hello friends,

I created an ActiveX OCX control called Virtual Forms. It's main focus is Excel. Yesterday I opened a Thread about it in Application Testing forum:

http://www.vbforums.com/showthread.p...nd-error-free)

or the webpage for the project is http://www.virtual-forms.com

For a long time I'm trying to find a way to get it to work in Office 64-bit.

I see that many of you here are the best of the best in this section (they visit this forum regularly that's why I'm posting it here and not in office or activex section).

Guys, I see that you managed to make it work for dll-s through ActiveX EXE

So, is there a way for OCX, maybe:

ActiveX OCX > ActiveX EXE (Out-of-process) > 64-bit

[RESOLVED] Send from FlexGrid to Excel

$
0
0
Hello VBForums
Hello every one
Merry Christmas
Please if you can help me to resolve and correct this code
I have a project in the folder mada in disk E ..mada is the name of folder
I have a command1 with code which sends FlexGrid data to Excel
Code:

Private Sub Command1_Click() 
Dim i As Long
Dim n As Long
On Error Resume Next
Set susanne = GetObject(, "Excel.Application")
If Err.Number Then
Err.Clear
Set susanne = CreateObject("Excel.Application")
If Err.Number Then
MsgBox "Can't open Excel."
End If
End If
susanne.Visible = True
Set christophe = susanne.Workbooks.Add
AppActivate "FlexGrid To Excel Demo"
For i = 0 To MSHFlexGrid1.Rows - 1
MSHFlexGrid1.Row = i
For n = 0 To 16                   
MSHFlexGrid1.Col = n
christophe.ActiveSheet.Cells(i + 1, n + 1).value = MSHFlexGrid1.Text   
Next
Next
End Sub

This code works very well but it saves the file excel in the documents of computer
I like it if you can help me please ( save ) the file excel in the same folder of my project whatever his location
Thank you in advance for help
Cordially
MADA

The focus is not properly controlled by Tab (SSTab) control

$
0
0
I have a Tab control on a form.
The tab control has several tabs.
On each one of these tabs I have a lot of controls (textboxes, checkboxes, commandbuttons, etc.)
When I use the keyboard to navigate through all the controls on the screen (by continuously pressing the tab key, I move from control to control, until I reach the last control on the current tab. Then when I press the tab key again and again, the focus is lost.
After investigation, I realized that the focus navigates to other controls on the screen that are on other tabs (other than the current tab)!!!
For example if the first tab is active (tabMain.Tab = 0), and I keep pressing the tab key until I reach the last control on this tabMain.Tab = 0, then after that when I press the tab key again, the focus goes to controls that are on tabMain.Tab = 1 !!!
In order to prevent this bizzare behaviour I have created a Frame array. Each member of this Frame array which is an individual Frame, is placed on a different tab of the Tab control.
Then I have placed all controls that are supposed to be on a specific tab of the Tab control, on the corresponding Frame.
For example every control that is supposed to be on tabMain.Tab = 0 is now on fraMain(0) which is itself on tabMain.Tab = 0.
And every control that is supposed to be on tabMain.Tab = 1 is now on fraMain(1) which is itself on tabMain.Tab = 1.
And so on.
Now I am trying to write a generic piece of code to control the navigation problem:
Code:

Public Sub TabNavControl(ByRef TheTabCtrl As SSTab, ByRef TheFraCtrl As Frame)

  Dim i                            As Long
  Dim CurrTab                  As Long
  Dim TabCount                As Long

  'Init
  CurrTab = TheTabCtrl.Tab
  TabCount = TheTabCtrl.Tabs

  'Main
  For i = 0 To TabCount - 1
      TheFraCtrl(i).Enabled = (CurrTab = i)
  Next i

End Sub

But the above procedure gives an error on this line "TheFraCtrl(i).Enabled = (CurrTab = i)":
Compile error: Wrong number of arguments or invalid property assignment

If I change this line "Public Sub TabNavControl(ByRef TheTabCtrl As SSTab, ByRef TheFraCtrl As Frame)"
to "Public Sub TabNavControl(ByRef TheTabCtrl As SSTab, ByRef TheFraCtrl() As Frame)"
Then the above error goes away, but then the code that calls the above procedure gives an error:
Code:

Private Sub tabMain_GotFocus()
  Call TabNavControl(tabMain, fraMain())
End Sub

It gives this error: type mismatch: array or user-defined type expected
If I change "Call TabNavControl(tabMain, fraMain())"
to "Call TabNavControl(tabMain, fraMain)" (that is removing the parantheses), it still gives me the same error: type mismatch: array or user-defined type expected
Whatever change I make, it gives me an error one way or the other.
How can I fix this?
Please advise.
Thanks.

Auto suggest

$
0
0
Hi experts
I want to add a listbox under my search textbox that displays suggestions while the user is entering data.
The data that I want to display is in two fields f access database.
The first field is for FirstNames and the second is for LastNames.
To help my self the picture is illustrating my needs.
Allan is in the first field and Lichman in the second

Name:  aaaa.jpg
Views: 35
Size:  15.5 KB

I want to display all records with Allan name and their last names which are in the LastName field.
The user then chooses the one he needs.
Thank you very much for the help.
Attached Images
 

Drawing colour boxes with fill

$
0
0
I wish to draw a box with a backgound colour and a fill style.
More specifically, I want a box with outline coloured on red, the type7 crosshatch fillstyle and a dark grey background colour (swath).

The nearest I get is the following which does not show a backgound colour (on a picture control):

picTest.line (x1,y1)-(x2,y2),vbRed,B
Adding the F after the B will not show the cross hatch and only the backgound.

Thanks
PK

first day of month

$
0
0
have this var(as String):

MyVar="03/2016" (are dinamic but always this format MM/YYYY)

Based this MyVar how to have in var FirstDay(As Date) the first day of month?

in my case:
FirstDay=31/03/2016

Upload with Inet from form upload

$
0
0
Hi,
I'm uploading files to my server from several forms in the same program.
I have an MSInet control on each form with the same code and it works fine.
In order to avoid this duplication I would like to create an unique form dedicated to file upload.

So I created a new form with Inet control and all the code in the form_load event
Code:

Private Sub Form_Load()
Me.Show
On Error GoTo InetError
Inet.AccessType = icUseDefault
Inet.Protocol = icFTP
Inet.URL = "ftp://ftp.rudyv.be"
Inet.UserName = "xxxxxx"
Inet.Password = "******"
Inet.Execute , "PUT " & Chr(34) & Source & Chr(34) & " " & Chr(34) & "/" & Destination & Chr(34)
While Inet.StillExecuting
    DoEvents
    Sleep 1000 '1sec
    DoEvents
Wend
Inet.Execute , "CLOSE"
While Inet.StillExecuting
    DoEvents
    Sleep 1000 '1sec
    DoEvents
Wend
On Error GoTo 0
Exit Sub

InetError:
MsgBox ....
On Error GoTo 0
End Sub

This does not work, the file is not uploaded, the Inet_StateChanged sub is never triggered.

If I put the same code in a button_click event on the same form instead of in the form_load event, when I click on the button it works fine.
So I guess it doesn't work in form load because at that moment the form is not completely loaded yet, or something like that.
How can I start the code after the form is loaded without requesting an action from the user ?

Send email in a simple VB6 project using a command1 button gmail smtp

$
0
0
i want a project code example using command1 button to submit a email using gmail smtp to submit a email to my destinated gmail email address using a single click

Setting Last DLL Error

$
0
0
I have an ActiveX DLL with API calls which at times generates error codes that I want to pass along to the caller.

The problem is that by the time the ActiveX has completed it's work, the Last DLL values have been cleared / overwritten preventing the caller from getting detailed error information, at least I think this is what’s happening.

I’ve tried using SetLastError just before exiting from the ActiveX hoping that the calling program will be able to retrieve the error information by using GetLastError, but it always returns a zero.

Is this the proper way to pass on errors from a DLL?

Thanks.

Serial Communication

$
0
0
Hello All :),

I am a Newbe to Visual Basic 6 and am wondering if Visual Basic 5 Professional is just as good as Visual Basic 6 Enterprise which I downloaded. I want to use this for serial communications so it seems I must have a registered piece of software. Any comments or opinions on my stupidity?

Missing Reference - but which

$
0
0
Finding an error for Environ("Temp") until I specify VBA.Environ("Temp")

I think this is caused by a missing reference which may mean other problems to come. How can I determine which one to add?
Those existing now are:

Visual Basic For Applications
Visual Basic runtime objects and procedures
Visual Basic objects and procedures
OLE Automation
Microsoft XML, v2.6
Microsoft DAO 3.51 Object Library

Thank you.

Form won''t show

$
0
0
Everything was going reasonably OK and I added a couple of combo boxes to my Form.
Suddenly it will no longer show. Any thoughts?

I removed the combo boxes but it made no difference.

My Startup Object is Form1 and it does exist. I get to the Form Load procedure OK... and can Stop there.

But I click on Start and Nothing...

On Error Goto problem - It just doesn't go there

$
0
0
Code:

       
On Error GoTo e
For Each Target in Targets
        Set W = New WinHttpRequest
        W.Open "GET", TargetConfig.URL, True
        W.Send
        W.WaitForResponse 'TargetConfig.WaitTimeMillsecs

e:
Next


When there is no Internet connection, the program will collapse due to an unhandled error. I don't know what's wrong. I already have an error trapping measure here. And when testing in the IDE, the code still breaks at the red line, instead of label e.

The error says the "Unable to resolve DNS".

Merry Christmas guys!!!

Listbox

$
0
0
Can I have a listbox control open 'expanded' so you can see/ select any item ?

At the moment it shows one item and has tiny scrollbars.

Or, should I be using a combo box instead? I though not though, as the User should select something from the list.

Thanks.

Property Member Help Text

$
0
0
Does anybody know how to edit the line item help for individual property members of a UserControl?

I know that there is an attribute line that goes in the .CTL file which defines the help text, but I was wondering if there is a way to edit it from within the IDE.

Thanks
Viewing all 22066 articles
Browse latest View live


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