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

problem with change result

$
0
0
Hello VBForums
Hello every one
Please gentelman
Please how can we solve this problem ..
I had a small project
It works very well and all the computing operation are fair
I reinstall Windows and also VB6
I nothing touched and I have nothing add or remove
The unfortunately not I found that the operations are changed for example ;
The amount I have before i reinstalled windows is ( 69266.15 ) this amount is right
Now after i reistalled windows this amount changed at ( 69266.50 )
Thank you in advance for help me
Cordially
MADA BLACK

[RESOLVED] Allow only string values

$
0
0
Hi programmers of vb6
I am using this code to save a picture

Code:

Dim FileName As String
cdlg.DefaultExt = "jpg"
cdlg.FileName = ""
cdlg.InitDir = App.Path
cdlg.DialogTitle = "File save"
cdlg.ShowSave
FileName = cdlg.FileName

If IsNumeric(FileName) = True Then
MsgBox "invalid name"
Else
SavePicture Picture1.Image, FileName

        End If

I wish to prevent saving a picture with an integer value.
I just want to allow string values.
But I couldn't figure out
thanks for the help

vb6 IDE Debug activex exe

$
0
0
hello,

I was just wondering if anyone here has moved to windows 10 and used the vb6 IDE in that environment. I got my vb6 installed and up to date with service pack 6, but when I run in debug mode, my app crashes. In windows 7 it worked fine. I am running a activex exe. Anyone else have an issue with this?

Thanks
WP

run program in one computer only

$
0
0
hello to all,

how can i run my program only in one computer using simple code because i am new in visual basic 6.


thank you in advance

jhay

System.IO.IOException occurred in mscorlib.dll

$
0
0
(Sorry just realised this is probably in the wrong section. I've now posted in the vb.net section.)

Hello,
I'm pretty much a beginner when it comes to vb and programming in general. I'm making a simple checklist program and have only one thing left to do - save functionality. I have already implemented a working version of loading using opendialog. I had a working version of saving which would save the text from texts boxes, the value of checkboxes and the dates required to a plain text file, though this would append the text in an existing file rather than replace it. I then attempted to fix this, which is where I'm at now, upon saving a text file is created, but none of the information is saved to it, as well as this, if I then change/edit any of the information in the checklist and attempt to save it again I get the IOexception. I have attached a screenshot for clarity. Here is my code for the saveAs menu item:

Code:

 
Private Sub SaveAsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveAsToolStripMenuItem.Click
        Dim Save As SaveFileDialog = New SaveFileDialog
        Dim FileName As String = Save.FileName ' retrieve the full path to the file selected by the user
        'Dim sw As New System.IO.StreamWriter(FileName, False) 'Streamwriter uses filename selected as path and sets append to false

        Save.Filter = "Plain Text Files (*.txt)|*.txt|All files (*.*)|*.*"
        Save.CheckPathExists = True
        Save.Title = "Save"

        If Save.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Dim sw As IO.StreamWriter = New StreamWriter(Save.OpenFile())
            Try

                sw = System.IO.File.AppendText(Save.FileName)
                sw.WriteLine(taskTextbox1.Text) ' Write the contents of TextBox to the file
                sw.WriteLine(taskTextbox2.Text)
                sw.WriteLine(taskTextbox3.Text)
                sw.WriteLine(taskTextbox4.Text)
                sw.WriteLine(taskTextbox5.Text)
                sw.WriteLine(taskTextbox6.Text)
                sw.WriteLine(taskTextbox7.Text)
                sw.WriteLine(taskTextbox8.Text)
                sw.WriteLine(taskTextbox9.Text)
                sw.WriteLine(taskTextbox10.Text)
                sw.WriteLine(taskTextbox11.Text)
                sw.WriteLine(taskTextbox12.Text)

                sw.WriteLine(Checkbox1.Checked) 'Write the state of checkboxes to the file
                sw.WriteLine(CheckBox2.Checked)
                sw.WriteLine(CheckBox3.Checked)
                sw.WriteLine(CheckBox4.Checked)
                sw.WriteLine(CheckBox5.Checked)
                sw.WriteLine(CheckBox6.Checked)
                sw.WriteLine(CheckBox7.Checked)
                sw.WriteLine(CheckBox8.Checked)
                sw.WriteLine(CheckBox9.Checked)
                sw.WriteLine(CheckBox10.Checked)
                sw.WriteLine(CheckBox11.Checked)
                sw.WriteLine(CheckBox12.Checked)

                sw.WriteLine(completedPicker1.Value) 'Write the value of the datepickers to file
                sw.WriteLine(completedPicker2.Value)
                sw.WriteLine(completedPicker3.Value)
                sw.WriteLine(completedPicker4.Value)
                sw.WriteLine(completedPicker5.Value)
                sw.WriteLine(completedPicker6.Value)
                sw.WriteLine(completedPicker7.Value)
                sw.WriteLine(completedPicker8.Value)
                sw.WriteLine(completedPicker9.Value)
                sw.WriteLine(completedPicker10.Value)
                sw.WriteLine(completedPicker11.Value)
                sw.WriteLine(completedPicker12.Value)

                sw.Close() ' close the file

            Catch ex As Exception
            End Try
        End If
    End Sub




Name:  exception.jpg
Views: 19
Size:  48.8 KB
Attached Images
 

Calculating tank Calibration

$
0
0
Hi Team

I want to calculate tank of calibration given the following interval(height(mm)) with specific formula

height(h) in mm formula (L)
0-217 512+23.0145*h
217-500 1000+23.2341*h
etc

The report should be in format of

example

mm litres mm litres mm litres mm litres mm litres
0 1000 50 1319 100 1637 150 1956 200 2275
1 1006 51 1325 101 1644 151 1962 201 2281
2 1013 52 1331 102 1650 152 1969 202 2287
3 1019 53 1338 103 1656 153 1975 203 2294
4 1025 54 1344 104 1663 154 1982 204 2300
5 1032 55 1351 105 1669 155 1988 205 2307
6 1038 56 1357 106 1676 156 1994 206 2313
7 1045 57 1363 107 1682 157 2001 207 2319
8 1051 58 1370 108 1688 158 2007 208 2326
9 1057 59 1376 109 1695 159 2013 209 2332


Any idea pls i have tried with vba but is not working. Now i am seeking any idea

Job Number Duplicates

$
0
0
I have a procedure which creates a new Job Number:
Code:

Private Sub cmdAdd_Click()
Dim strSystemJobDate As String 'variable to hold first part of the full JobNumber
Dim strSystemJobNumber As String 'variable to hold second part of the full JobNumber
Dim strMyJobDate As String 'variable to hold first part of the full JobNumber, for instance 9710
Dim MyMonth As String
Dim MyYear As String
Dim rsTemp As ADODB.Recordset
    On Error GoTo ErrorHandler
        'read the last used Job Number from the table
        Set rsTemp = New ADODB.Recordset
        rsTemp.Open "SET NOCOUNT ON; SELECT JobNumber FROM JobNumber", objConn, adOpenStatic, adLockPessimistic 'cndTemp.Execute
       
        strSystemJobDate = Left$(rsTemp.Collect("JobNumber"), 4)
        strSystemJobNumber = Right$(rsTemp.Collect("JobNumber"), 4)
        MyMonth = CStr(Month(Date)) 'find out the current month
        'add zero in front of month if it contains only 1 digit
        If CInt(MyMonth) < 10 Then
            MyMonth = "0" & MyMonth
        End If
        'trim two last digits from the current year
        MyYear = Right$(Year(Date), 2)
        strMyJobDate = MyYear & MyMonth 'variable looks like 0403
   
        'create new value of the second part of the Job Number
        If strMyJobDate = strSystemJobDate Then
            strSystemJobNumber = CStr(CLng(strSystemJobNumber) + 1)
        Else
            strSystemJobNumber = "1"
        End If
   
        'change the value of variable to the current one
        strSystemJobDate = strMyJobDate
        'create 4 character number
        strSystemJobNumber = Right$("000" & strSystemJobNumber, 4)
   
        'write to Table the last used Job Number
       
        strJobNumber = strSystemJobDate & "-" & strSystemJobNumber
       
        rsTemp.Collect("JobNumber") = strJobNumber

        rsTemp.Update
       
        txtJobNumber = strJobNumber
        txtCreationDate = Date
       
        EnableUpdateButton
        txtJobName.SetFocus
    Exit Sub
   
ErrorHandler:
    MousePointer = vbDefault
    MsgBox "Error: " & Err.Number & ", '" & Err.description & " in cmdAdd_Click. Report to your Administrator.", vbCritical + vbOKOnly, "Error"
End Sub

25 users work with this application and I would say that 15-20 new jobs are created by using this procedure every day.
The database table for jobs has a field JobNumber which is populated with the Number generated by this procedure. The field doesn't have any restriction on that field (unique value etc.). 4-5 times a year something happens and we get duplicates in the Jobs table in the database.
What can be the reason?
The database design is not my department, so, I cannot change the design of the table. The data is stored in MS SQL Server.
Any advice how to prevent duplicates please.

Thank you

Thank you all for the help you offered me-

$
0
0
I have never seen a forum that it is as helpful as this one
You are so kind and helpful
You helped me to solve many of my problems
I'm so grateful to you

need help adding times that result in more than 24 hours

$
0
0
I have a program that tracks student visits to different areas of the school. Nurse, Guidance, APO, etc. Students scan their ID and an entry is written to an access database. One of the tables in the database keeps track of total visits and total duration of visits.

I am using VB6 and everything works fine until the total time reaches more than 24 hours. at that point the total time starts back over at 0.




in one sheet I write the time of check in and check out and use the following commands:

to calculate the duration of each visit:

Format(DateAdd("s", DateDiff("s", Start-Time, End-Time), "00:00:00"), "hh:mm:ss")



I convert the visit to seconds with this command:

ss = DateDiff("s", Start-Time, End-Time)



in a different sheet I find the running total time and convert it to seconds:

sss = Total-Time * 86400




I add ss and sss together (ss=ss+sss) and convert it back to hh:mm:ss using:

Format(DateAdd("s", ss, "00:00:00"), "hh:mm:ss")



I need the total time to hold more than 23 hours 59 minutes and 59 seconds before starting back over at 0

Any help would be greatly appreciated!

printing dialog dont print

$
0
0
Scratching my head on this one. I may need to do my studying on print dialogs but the following code brings up the print dialog, but it doesnt print the active form in the MDIform.

Private Sub cmdPrint_Click()
Dim BeginPage, EndPage, NumCopies, Orientation, i
CommonDialog1.CancelError = True
On Error GoTo ErrorHandler
CommonDialog1.ShowPrinter
BeginPage = CommonDialog1.FromPage
EndPage = CommonDialog1.ToPage
NumCopies = CommonDialog1.Copies
Orientation = CommonDialog1.Orientation
For i = 1 To NumCopies


Printer.Print ActiveForm 'here's the error, but i cant get the right syntax
Next
Exit Sub
ErrorHandler:

End Sub

Will Windows 10 Really Grind Your Gears?

$
0
0
Name:  Gears.png
Views: 54
Size:  5.1 KB

While fiddling with DPI-Awareness I ran into something I hadn't expected.

On a Windows 10 machine (I don't have Windows 8 or Windows 8.1 handy to test on, though I suspect something similar occurs)... I saw that resizing a VB6 program's Form at runtime was a "live" process instead of updating after I released the mouse button. Clearly there can be an impact to this.

In theory the DWM is "always on" in the post-Win7 world. However this is separate from Aero themes which are gone, yet it appears we have most of the expense of Aero with none of the benefits. And on top of that now we have events coming faster and more furiously than ever before.

If you don't have Resize and Paint handlers or they're very lightweight there is no issue.

Not being a "graphics guy" I may be off in the weeds here, but I had the idea that before you get very far you need to abandon AutoRedraw windows and start rendering during the Paint event. And of course this means you need to recreate your entire rendering for things like resizing, restore from minimized, or just when another window uncovers you.


So anyway, here's a simple test program. The program was run, then it was resized larger and then resized smaller again (two resize operations by the user).

Name:  sshot1.png
Views: 46
Size:  16.4 KB

Test on Vista SP2


Name:  sshot2.png
Views: 47
Size:  35.0 KB

Test on Windows 10


To try to keep issues to a minimum the program is not marked DPI-Aware, so since the display was at 125% DPI the program got DPI-virtualized and fonts and such are blurred.

Getting to my point (finally):

Look at the wildly higher counts of display-related events!

It seems to me that a program with adequate performance under Windows Vista and Windows 7 might suffer quite a bit when run under Windows 10 (and perhaps Windows 8 and Windows 8.1 as well).

Am I missing something here or does Windows 10 make your Resize and Paint even handler code far more performance-critical than in "the good old days?"
Attached Images
   
Attached Files

Existent files not found - only after use of Explorer

$
0
0
Hi,

I have written a program (P2) that makes use of files that are written by another program (P1, also from me).

On a regular basis I experience this problem:
- In P2 when trying to open a file that I know P1 must have written to disk (SDD) P2 receives the error message "file not found".
- When I open MS Windows Explorer look into the folder were the file (from P1) is located I can see that it is there (need to press F5 button in Explorer to update the view)
- After this (the Explorer thing) when running P2 it correctly finds the file written by P1

Do you have any explanations what's happening here (it is all 100% replicable)?

What can be done?

Thanks for all suggestions.

Add Project Not Working Under W7

$
0
0
I have a weird issue under W7-HP. From the VBDE File menu, if I try to create a Project Group (Add Project) using one of my existing projects I get a VB prompt "A project with the same name 'Project1' is already loaded". That would make sense if it were true but it isn't. To further befuddle me, it will load another project only if I select it from the New tab. VB will assign it a default name 'Project2' even though the current project does not own the name 'Project1'.

Thanks,
Chris

Save the Listview content

$
0
0
Hello
My concern is about storing the listview content in a listview
One of the gentelmen here (Tech99 ) gave this code to store controls' properties on a form in ini file
For reading
Code:

Ctl.Text = ReadFromAppINI(Me.Name & "Control", Ctl.Name & " text", Ctl.Text, App.Path & MyAppIni)
For writing
Code:

  Retval = WriteToAppINI(Me.Name & "Control", Ctl.Name & " text", CStr(Ctl.Text), App.Path & MyAppIni)
Everything is perfect
Now what I wish to do is storing the listview data in the same file.(ini file)
I tried in this way but I get an error

Code:

For Each Ctl In Me.Controls
If TypeOf Ctl Is ListView Then
  For x = 1 To Ctl.ListItems.count
Retval = WriteToAppINI(Me.Name & "Control", Ctl.Name & " text", CStr(Ctl.ListItems(x).Text), App.Path & MyAppIni)
Next

End If
Next

Please tell me how to store the listview items in an ini file
thanks a lot
Attached Images
 

all txt files in one...

$
0
0
I have in c:\mydir\ a lot of txt files, named for example TEST_12012015, TEST_14072013.... eccc


i nee to loop in c:\mydir\ and append all files in one c:\mydir1\TOTAL_file.txt, but only the txt with the format name TEST_DDMMYYYY.txt

how to?

note:
-the name of all files have the format: TEST_DDMMYYYY.txt, for all.
-in the dir i can have other txt file but not important for me
-i hve in dir approx 342 file with the format TEST_DDMMYYYY.txt

The application freezez without any error

$
0
0
Hello
I'm trying very hard to save the listview items in access table but each time I click the save button, the application freezes. (stucks)
This is my code:
Code:

If RS.State = adStateOpen Then RS.Close
    For a = 1 To lvw1.ListItems.count
 For b = 1 To lvw1.ListItems(a).ListSubItems.count

  Set RS = New ADODB.Recordset

RS.Open "select plan, doc, unit from MyTable" & _
        " where plan= '" & lvw1.ListItems(a).Text & "' " & _
        " and doc= '" & lvw1.ListItems(a).ListSubItems(1).Text & "' " & _
        "  and unit = '" & lvw1.ListItems(a).ListSubItems(2).Text & "'", _
        DB, adOpenDynamic, adLockOptimistic     
        If Not RS.BOF Then
      RS!plan= lvw1.ListItems(a).Text
      RS!doc= lvw1.ListItems(a).ListSubItems(1).Text
      RS!unit= lvw1.ListItems(a).ListSubItems(2).Text
            RS.Update
            Else
            RS.AddNew
      RS!plan= lvw1.ListItems(a).Text
      RS!doc= lvw1.ListItems(a).ListSubItems(1).Text
      RS!unit= lvw1.ListItems(a).ListSubItems(2).Text
  RS.Update
  End If
  Next
  Next
    RS.Close: Set RS = Nothing
    DB.Close: Set DB = Nothing

thanks in advance

how to break line in rich text box if certain word is at the end of line.

$
0
0
Hi guys,
I need a help to break a line in Rich Text Box, if the last word of the RTB line is "End"

Rich text box contains a RTF file and contains word "End" many times in the RTF File, with multiline enabled = true.

please guide, how can i do it ?
Thanks in advance.

[RESOLVED] keyboard

$
0
0
Hello VBForums
Hello every one
Is that it is possible to appears the keyboard by commandbutton ??
Thank you in advance for any idea
Cordially
MADA BLACK

Non-normalized data

$
0
0
I have a report that gets employee data from a table (Table A). The report works fine. Now, the user wants to include data from Table B. The problem with Table B is that the data is not normalized. Each record in Table B allows for 6 employee numbers.

So, the user wants employee information about work performed for a date on a given production line. That is working. The addition is for those times when the employee did no accrue 8 hours on the production line. The remainder of their time should be in Table B (where they are doing something else). Out side of the employee number and the date, there is little connection between the data in the 2 tables.

I seem to be given a choice of using aliases or creating subreports linking the employee number and date. So, I have Table_A.EmployeeNumber and need to link to one of the fields: Table_B.Employye1, Table_B.Employee2, Table_B.Employee3, Table_B.Employee4, Table_B.Employee5, or Table_B.Employee6. If I find a connection, I can report their time from Table_B.

Any suggestions?

Farpoint fpSpru70.ocx, printing differently when Locale is set 2052 or 1041

$
0
0
Hello,

When invoking ssMain.Action = ActionSmartPrint for farpoint 70 fpSpru70.ocx within VB 6 running on Windows Server 2008 r2 Standard, and Locale is set to 2052(Chinese Simplified) or 1041(Japanese), the spreadsheet print out to a network printer is different ; in both cases, not as readable. Compared to locale setting 1033, the printout for 2052 is faint and the font has changed. For 1041, the font is the same as well as the boldness but the size of the print is much smaller. Right before the ssMain.Action = ActionSmartPrint is invoked, I see no change in the properties for the printer device or for the farpoint spreadsheet control when switching from locale 1033 to 2052 or 1041. Within our applications, this appears to be only an issue with the farpoint spreadsheet. All other screen prints of VB 6 forms with standard user controls look the same. Some how, the locale setting is affecting the printing of the Farpoint grid control when invoking ActionSmartPrint. Any help with this matter would be much appreciated.

Thanks and cheers,

John
Viewing all 22070 articles
Browse latest View live