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

Monitoring keydown events in MDI form?

$
0
0
I've a mdiform where sometimes a mdichild (one or more) are loaded and sometimes there isn't any mdichild form loaded.

I want to use keyboard shortcuts for specific tasks (for example control+B to show a mdichild, alt+2 to change graphic parameters of an opened mdichild, etc). I've been looking in the forum and some guy said to use a picturebox control in the background of the mdiform and at the end of the keydown event use
Code:

Picture1.SetFocus
The problem is when I use that solution, no mdichild form can be seen on the mdiform. I think the mdichild is behind of the picturebox control.

So, what solution can I use? Remember that the mdiform has some key shortcuts and the mdichild forms have different key shortcuts.

webrowser click button

$
0
0
Hi Guys,

Using webbrowser in vb6 i try to click a website button
HTML code:
<div class="btnSiguiente">
<input type="image"
src="http://89.202.162.60/imagenes/siguiente.gif" alt="SIGUIENTE">
</div>


You can download the vb6 project to go faster and easier.

http://www.mediafire.com/download/1j...oyecto+vb6.rar


I read and tried many different choices for a week but I can not find the right one...

Help me please , thanks in advance

Best Regards

[RESOLVED] How to manage the same variable in multiple forms?

$
0
0
I've a mdi parent form where I load mdichild forms.
These forms are exactly the same form. And I load them one by one using
Code:

Dim MyForm As New frmMain
Load MyForm
MyForm.Show

Well, in each form that the user opens the program has to hold the zoom level in a variable. My question is how can I manage that situation.

I've created a module where I declare
Code:

Public ZoomLevel As Integer
Well, this variable can only hold the zoomlevel of one window.
What is needed to modify in that code to hold the zoom level of each opened window?
When there are N opened forms and I select a different one,
How can I read and modify the zoom level of that form?

I've thought about using an array, but I don't know if there is another solution. What is the best option?

[RESOLVED] What happens if we "Re New" an object?

$
0
0
vb Code:
  1. Dim c As Collection
  2.     Set c = New Collection
  3.     c.Add "123"
  4.     Set c = New Collection
  5.     c.Add "333"

Choosing a file and write the location of the file in a text file in VB6

$
0
0
Friends, I am not getting how to Choosing a file option in VB6. I want to create it like this.
Name:  kgb-archiver-9.png
Views: 78
Size:  9.2 KB
Each File added a text "Filelocationwithfilename" "Filelocationwithfilename" in text file would be automatically added after an another button would be pressed.
I am trying this for hours and I have not slept yesterday properly for this.
Thanks in advanced.
Attached Images
 

Is there a better way to write this function?

$
0
0
Code:

Function mSplit(InputString As String, _
                Optional Delimiter As String = " ", _
                Optional SetRstArrayLowerBoundTo As Long = 0, _
                Optional OutputRstArrayUpperBound As Long, _
                Optional LastStringElement As String, _
                Optional CompareMode As VbCompareMethod = VbCompareMethod.vbTextCompare) As String()

    Dim RstStringArray() As String
    Dim TempStringArray() As String
    Dim I As Long, K As Long

    If SetRstArrayLowerBoundTo = 0 Then

        RstStringArray = Split(InputString, Delimiter, , CompareMode)
        OutputRstArrayUpperBound = UBound(RstStringArray)
        LastStringElement = RstStringArray(UBound(RstStringArray))

    Else

        TempStringArray = Split(InputString, Delimiter, , CompareMode)
        ReDim RstStringArray(SetRstArrayLowerBoundTo To SetRstArrayLowerBoundTo + UBound(TempStringArray))
        K = LBound(TempStringArray)
        For I = LBound(RstStringArray) To UBound(RstStringArray)
            RstStringArray(I) = TempStringArray(K)
            K = K + 1
        Next

        OutputRstArrayUpperBound = UBound(RstStringArray)
        LastStringElement = RstStringArray(UBound(RstStringArray))

    End If

    mSplit = RstStringArray

End Function

Basically I want to write a function that supplements the built-in split function which only returns a string array lower bound starting from 0.

Is this function looks OK? Or is there a better way to write it to make it more readable and efficient?

Or is it completely unnecessary to make this function? I am just hoping to save some typing in some cases.

I want to build some basic functions for my own use and I am just starting to do it. Anyone can point me a way? I'm just a programming hobbyist.

[RESOLVED] vb6 using vb.net dll runtime error result

AscW returns negative value

$
0
0
For some CJK Characters, AscW returns negative value. It's nothing wrong because AscW returns integer, The negative value can add 65536 to convert to UTF-32 (Long Type). But I am not sure whether it is always true. What I know is that Unicode numbers occupy a 16-bit positive range from 0 to 65535 (0xFFFF), and cannot be negative. But someone said the supported character code range is from 0 to 1114110. For this case, adding 65536 is no more correct. Please advice what is the solution in VB6?

In C# and JAVA, We just simply write:

Char uniChar = '者';
int ascw;
ascw = (int)uniChar; // uniChar 64091 '者' char 0xfa5b

create a new printer paper form

$
0
0
You can create a new printer paper form and size on Print Server Properties and do it manually. But I am looking on how to create it programmatically using vb6 or vb.net dll . Does anyone has already done this ?

I have been searching the internet for 2 hours now but cant find here to it or maybe I am using the wrong search keyword.

[RESOLVED] Getr value of color font in listview item

$
0
0
I loop all items in a listview column.
each item have a different color font.
is possible to retrive the value of single color font of items?

[RESOLVED] External file algorythm. How?

$
0
0
I've a program that opens a file, read its content and displays the content in a form. It can be compared with an audio editor where the user opens an audio file, the program reads the data inside the file and shows the waveform in the form.

Well, after the data is shown in the form, the user can add some filters to the graph to study some parameters of the file. I know I can introduce the code in the program, but I want to know if there is a way to create an external file containing the algorythm instead of writting the algorythm in the program code.

There is any way to accomplish that? If so, it's very difficult?

[RESOLVED] AscW returns negative value

$
0
0
For some CJK Characters, AscW returns negative value. It's nothing wrong because AscW returns integer, The negative value can add 65536 to convert to UTF-32 (Long Type). But I am not sure whether it is always true. What I know is that Unicode numbers occupy a 16-bit positive range from 0 to 65535 (0xFFFF), and cannot be negative. But someone said the supported character code range is from 0 to 1114110. For this case, adding 65536 is no more correct. Please advice what is the solution in VB6?

In C# and JAVA, We just simply write:

Char uniChar = '者';
int ascw;
ascw = (int)uniChar; // uniChar 64091 '者' char 0xfa5b

Visual Studio 6.0 in Windows 8 64bit

$
0
0
Can I install and use VB6 on Win8 64bit without any problem?
If any, I should downgrade to Win7 64bit.
If there's any problem in 64bit, I should use XP.

How to implement "Globals" for my ActiveX Dll Project?

$
0
0
Name:  QQ??20150609104315.png
Views: 83
Size:  2.4 KB

See the above screenshot where the "globals" has nothing in it.

The thing is if I write an ActiveX Dll Project and create my own classes, I will have to declare and instantiate the classes before I can use their methods and properties. When I reference to dlls made by other people, usually the "globals" contains a couple of functions and constants that I can use anywhere without instantiating anything after just "referencing".

I tried hard to figure out how to make a "globally available" function but without much results. i.e. I tried to write public functions in the project's standard module but that function appears to be available only globally within the project itself, rather than globally available, or shown in F2 object browser, in the referencing project.

Need some help here.
Attached Images
 

WebBrowser control script error for certain url

$
0
0
Hi..
I got script error when try to navigate to
Code:

https://www.worldcat.org/title/lelaki-versi-dia/oclc/849685976&referer=brief_results
here the script error:
Name:  html.png
Views: 44
Size:  35.8 KB
Attached Images
 

Unknown Project Name

$
0
0
Hi everyone,

I'm creating a project which I do not know what name to give, but beforehand I have named "Project Maker".
So I ask you all for a little of patience and some help and support please. so far this is the code of my project:
Code:

Sub Add()
Dim myParas As Variant
Dim i As Integer
myParas = Split(Text2, vbNewLine)
Dim a() As String
a = Split(Text2, vbNewLine)
For i = 0 To UBound(myParas)

List1.AddItem "Sub " & a(i) & Text3.Text & "()"
List1.AddItem ""
List1.AddItem "End Sub"
List1.AddItem ""

Next
End Sub

Sub Safe()
Dim i As Long
Open "List.txt" For Output As #1
For i = 0 To List1.ListCount - 1
Print #1, List1.List(i)
Next i
Close #1

Text2 = ""
List1.Clear
End Sub

Private Sub Command1_Click()
Add
Safe
End Sub

This project require 1 Listbox, 2 Textboxes, and one button.
The idea and purpose of this project is to create a code which will be saved in a text document.
The Listbox have the following text:
Coding_
Project_
Unfinished_
My intention is to add a number to each line of text, like for example:
Coding_1
Project_2
Unfinished_3

and so on, depending on how many lines I add or paste on the textbox.
thats the reason I added the Textbox3 but I've been scraching my head
on how to generate those extra numbers to each line that will be passed
from the Textbox to the Listbox, will be very nice if I could get some help.
If I have to upload the project so you guys could look at it I can upload it.
thanks in advance.

VB6 - Collision with multiple objects + Gravity - Need Help!

$
0
0
So as of now I am trying to create my first platformer game and in this game the player ( A square shape) needs to be able to land/ collide with platforms. So far I have that working (even though I probably can make it better, since I didn't use any tutorials to make it because they don't explain how to use the code normally or how it works). But whenever I add gravity (through the use of a timer or the game loop) it passes right through the object. I've been stuck at this point for a couple of days searching for solutions and messing around with it, but couldn't find a solution. Here's my code so far (Sorry for it being inefficient, I'm still a novice!):

Code:

Option Explicit 'Checks for undefined variabls

Private Declare Function GetTickCount Lib "kernel32" () As Long

Dim Pause As Boolean      'Checks if game is paused
Dim Running As Boolean    'Checks if game is started

Dim CRight As Boolean      'Right side collision
Dim CLeft As Boolean      'Left side collision
Dim CTop As Boolean        'Top side collision
Dim CBottom As Boolean    'Bottom side collision

Private Sub Form_Load()
    Running = True        'Game is on
    Main                  'Start main loop
End Sub

Private Sub Main()                                  'The main loop

    Dim TempTime As Long                            'To keep track of time
    Dim Fps As Double                              'Current fps/Frames Per Second
    Dim FrameCount As Long                          'Count frames between fps update
   
    While Running                                  'Checks if the game is running
       
        If TempTime <= GetTickCount Then            'Checks if its time to calc next frame
           
            TempTime = GetTickCount + 10            'set next tick time
           
            While Pause                            'Checks if game is paused
                DoEvents                            'infinit loop
            Wend
           
           
            'GAME CODE:
           
            CheckCollision
            Testing
           
           
            'END OF GAME CODE
           
           
            FrameCount = FrameCount + 1            'fps counter
           
            If Fps + 1000 <= GetTickCount Then
                Me.Caption = "Fps: " & FrameCount  'Printing the actual fram count
                Fps = GetTickCount
                FrameCount = 0
            End If
           
        End If
       
        DoEvents                                    'Handle win msgs
       
    Wend
   
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

    Running = False                'game over
   
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim intI As Integer
    If KeyCode = vbKeyP Then      'Pauses code
   
        If Pause = False Then
            Pause = True
            Me.Caption = "Paused"  'Displays on form caption
        ElseIf Pause = True Then
            Pause = False
        End If
       
    End If
   
For intI = 0 To 2 'Tests collision between multiple objects

    'Checks if left side is colliding with anything
    If shpPlayer.Left <= shpBlock(intI).Left + shpBlock(intI).Width And shpPlayer.Left + shpPlayer.Width >= shpBlock(intI).Left + shpBlock(intI).Width And shpPlayer.Top + shpPlayer.Height >= shpBlock(intI).Top And shpPlayer.Top <= shpBlock(intI).Top + shpBlock(intI).Height Then
        CLeft = True
    Else
        CLeft = False
    End If
   
    'Checks if right side is colliding with anything
    If shpPlayer.Left + shpPlayer.Width >= shpBlock(intI).Left And shpPlayer.Left <= shpBlock(intI).Left And shpPlayer.Top + shpPlayer.Height >= shpBlock(intI).Top And shpPlayer.Top <= shpBlock(intI).Top + shpBlock(intI).Height Then
        CRight = True
    Else
        CRight = False
    End If
   
    'Checks if top side is colliding with anything
    If shpPlayer.Top <= shpBlock(intI).Top + shpBlock(intI).Height And shpPlayer.Top + shpPlayer.Height > shpBlock(intI).Top + shpBlock(intI).Height And shpPlayer.Left + shpPlayer.Width >= shpBlock(intI).Left And shpPlayer.Left <= shpBlock(intI).Left + shpBlock(intI).Width Then
        CTop = True
    Else
        CTop = False
    End If
   
    'Checks if bottom side is colliding with anything
    If shpPlayer.Top + shpPlayer.Height >= shpBlock(intI).Top And shpPlayer.Top < shpBlock(intI).Top + shpBlock(intI).Height And shpPlayer.Left + shpPlayer.Width >= shpBlock(intI).Left And shpPlayer.Left <= shpBlock(intI).Left + shpBlock(intI).Width Then
        CBottom = True
    Else
        CBottom = False
    End If


    Select Case KeyCode 'Moves the character
                       
        Case vbKeyLeft
            If CLeft = False Then
                shpPlayer.Left = shpPlayer.Left - 25
            Else
                shpPlayer.Left = shpPlayer.Left + 50
            End If
        Case vbKeyRight
            If CRight = False Then
                shpPlayer.Left = shpPlayer.Left + 25
            Else
                shpPlayer.Left = shpPlayer.Left - 50
            End If
        Case vbKeyUp
            If CTop = False Then
                shpPlayer.Top = shpPlayer.Top - 25
            Else
                shpPlayer.Top = shpPlayer.Top + 50
            End If
        Case vbKeyDown
            If CBottom = False Then
                shpPlayer.Top = shpPlayer.Top + 25
            Else
                shpPlayer.Top = shpPlayer.Top - 50
            End If
    End Select
Next intI
   
End Sub



End Sub

Private Sub Testing() 'Display stats for testing

lblLeft.Caption = "Left: " & shpPlayer.Left
lblRight.Caption = "Right: " & shpPlayer.Left + shpPlayer.Width
lblBRight.Caption = "Right: " & shpBlock(2).Left + shpBlock(2).Width
lblBLeft.Caption = "Left: " & shpBlock(2).Left
lblTop.Caption = "Top: " & shpPlayer.Top
lblBottom.Caption = "Bottom: " & shpPlayer.Top + shpPlayer.Height
lblBTop.Caption = "Top: " & shpBlock(2).Top
lblBBottom.Caption = "Bottom: " & shpBlock(2).Top + shpBlock(2).Height

'*** "B" stands for "Block" ***
End Sub

If you guys have and suggestions, ideas, or questions about the code feel free to post and thank you in advance! :)

Copy one table to another table then insert data based on a given condition

$
0
0
Name:  vbproblem1.jpg
Views: 8
Size:  44.7 KB

I want to copy data in tblTemp to tblTimelogger then insert additional data in tblTimeLogger based on a given condition. I tried but i have no luck.

Kindly put comments on your code so that i can study how things to be done.

Thanks for the help..
Attached Images
 

Com object behaving weird in Window 2008

$
0
0
very new to VB programming

I have an VB 6 application that gets launched from a remote server through ESP client (scheduling application). The VB6 application starts executing and inside the VB6 application, another application is automated using COM component. This is done through call to createobject(Myapplication.application).

ON Windows 2003 everything works fine but on Windows 2008 this does not work.

The VB6 application calls a createobject to instantiate the external application but the program just hangs on Windows 2008. I ran process monitor and can see that application gets started but the process quickly exits with exit status of 0.I also noticed that the user profile on Windows 2008 for the application being created through COM component is the netword service account DOMAIN/computername$

On Windows 2003 where the same program work fine, the external application shows the local system account (NTService/local).

The VB6 appliation that created the COM component object is being run by a domain user which is part of the admistrators group.

when I run the VB6 application manaully( I mean logging into the server through RDP and double click on it then VB6 application and the external application runs fine. It is only when the ESP launches it throught the service account. although ESP will launch the VB6 application fine but the external application that gets launced inside the VB6 application starts but only to exit quickly.)

Why does external applicaiton created through COM component show network service accout as the user profile and how can I get that application to launch as the local system account in my VB6 application?


I have been struggling with this for months. Can someone explain com components and how Windows assignes user profile in respect to servcies running vs local user launching it?

Thank you in advance

[RESOLVED] Unknown Project Name

$
0
0
Hi everyone,

I'm creating a project which I do not know what name to give, but beforehand I have named "Project Maker".
So I ask you all for a little of patience and some help and support please. so far this is the code of my project:
Code:

Sub Add()
Dim myParas As Variant
Dim i As Integer
myParas = Split(Text2, vbNewLine)
Dim a() As String
a = Split(Text2, vbNewLine)
For i = 0 To UBound(myParas)

List1.AddItem "Sub " & a(i) & Text3.Text & "()"
List1.AddItem ""
List1.AddItem "End Sub"
List1.AddItem ""

Next
End Sub

Sub Safe()
Dim i As Long
Open "List.txt" For Output As #1
For i = 0 To List1.ListCount - 1
Print #1, List1.List(i)
Next i
Close #1

Text2 = ""
List1.Clear
End Sub

Private Sub Command1_Click()
Add
Safe
End Sub

This project require 1 Listbox, 2 Textboxes, and one button.
The idea and purpose of this project is to create a code which will be saved in a text document.
The Listbox have the following text:
Coding_
Project_
Unfinished_
My intention is to add a number to each line of text, like for example:
Coding_1
Project_2
Unfinished_3

and so on, depending on how many lines I add or paste on the textbox.
thats the reason I added the Textbox3 but I've been scraching my head
on how to generate those extra numbers to each line that will be passed
from the Textbox to the Listbox, will be very nice if I could get some help.
If I have to upload the project so you guys could look at it I can upload it.
thanks in advance.
Viewing all 21864 articles
Browse latest View live


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