hkdani 39 Posting Pro in Training

Your Sequel code should look something like this

Dim strSQL as string 
strSQL = _
"SELECT MyDates.* " & _  
"FROM YearlyDates " & _
"WHERE MyDates " & _
"BETWEEN  DateOne AND DateTwo"

You might have to monkey with setting up the date format: e.g. cDate("3/1/2009")

But you also need to establish an exact day for a reference point for your 6:00 AM and 6:00 PM. Which means you need a Month, a Day, and Year to make this work.

Don't know which type of Database you're using, but the above is more or less what you're looking for in a SQL string.

The DatePicker Value property is the Value you're probably looking to use in your program.

Dim DateOne as Date, DateTwo as Date

DateOne = DTPicker1.Value
DateTwo = DTPicker2.Value

That should give you a Date Value you can use.

Hank

hkdani 39 Posting Pro in Training

This should work. Might want to clean it up a bit and check the validity and logic of the Select Case Statement. It has some errors. I'll leave that to you to find. But something like the following:

Option Explicit
Dim dFirstDayMonth As Date, intMonth As Integer, strMonthDayOne As String
    Dim intFirstSaturday As Integer, intFirstDay As Integer
    Dim strDayOne As String, intPickedDay As Integer

Private Sub cmdFindWeek_Click()
    Dim intPickedDay As Integer
    Dim intMonthWeek As Integer
    intPickedDay = DTPicker1.Day
    intMonth = DTPicker1.Month
    strMonthDayOne = CStr(intMonth) & "/1"
    dFirstDayMonth = CDate(strMonthDayOne)
    intFirstDay = Day(dFirstDayMonth)
    ' First Saturday should always be the following:
    intFirstSaturday = 8 - intFirstDay
    intMonthWeek = FindWeek(intPickedDay)
    
    Text1 = "This is week " & CStr(intMonthWeek)
End Sub

Private Function FindWeek(CurrentDay As Integer) As Integer
Dim intFirstDayWeekTwo As Integer
intFirstDayWeekTwo = intFirstSaturday + 1
Select Case CurrentDay

Case 1 To intFirstSaturday
    FindWeek = 1
Case intFirstDayWeekTwo To intFirstDayWeekTwo + 6
    FindWeek = 2
Case intFirstDayWeekTwo  + 7 To intFirstDayWeekTwo + 12
    FindWeek = 3
Case intFirstDayWeekTwo + 14 To intFirstDayWeekTwo + 18
    FindWeek = 4
Case intFirstDayWeekTwo + 21 To intFirstDayWeekTwo + 24
    FindWeek = 5
Case intFirstDayWeekTwo + 28 To intFirstDayWeekTwo + 30
    FindWeek = 6
End Select

End Function
hkdani 39 Posting Pro in Training

You could use the MonthView Control.

The Week Property of that control returns that particular day's week number in relation to the current year.

For example

Dim intWeek as integer

intWeek = MonthView1.week

intWeek should return the week number for the particular day selected in the MonthView Control.

You'll probably have to extra coding to figure out which week it is in relation to the month, though.

hkdani 39 Posting Pro in Training

rs.Fields("Material_ID") = CLng(Grd.TextMatrix(CLng(row), 1))

Check the value of that TextMatrix. I would guess that it's a Null value. Put a break at that line of code and use your immediate pane to determine the error.

It would probably be a good idea to include error checking in that procedure to give you some more exact info.

Private Sub MyRoutine()
On error goto MyRoutine_ERROR
' Code .......
' ....

Exit sub

MyRoutine_ERROR:
debug.print err.description, err.number, err.source
resume next
End Sub()
hkdani 39 Posting Pro in Training

the same code works with text if the fields are text
what might be the problem?
please assist
thank you.

It's not the greatest practice to rely on VB6 to convert your variables from one type to another: i.e. text to integer, text to long, long to text, etc.

That's one reason you should set up your code in the options to use Option Explicit or in the Tools Menu choose Options, and in the Editor Tab make sure the Require Variable Declaration checkbox is checked.

If you're working with text boxes or string values, then it's good practice to go ahead and convert those values to the type that you are expecting to use in your database field before assigning them to a field.

Dim intValue as Integer
if isNumeric(txtValue.text) then
[INDENT]intValue = cInt(txtValue.text) [/INDENT]
else
[INDENT]intValue = 0[/INDENT]
End if
rst.Fields("PartNumber") = intValue

You also might want to include some type checking code as above in areas where it might occur that an incorrect type may be used in a field that expects a different value. And as always, it wouldn't be a bad idea to have error checking code in each procedure to handle errors such as you mentioned.

Private sub FillData()
On error goto  FillData_ERROR
...
...
...
Exit sub

FillData_ERROR:
if err.number = 15 ' Data type mismatch
   msgBox "Incorrect Data Type", vbCritical, "Error Message"
else
    debug.print err.description, err. number, err.source
endif
Resume Next

End sub()
hkdani 39 Posting Pro in Training

it gives me errors saying that the data is unable to be written to the excel sheet

Check the file properties. If you copied them straight from the CD, then they will automatically be set to read only.

hkdani 39 Posting Pro in Training

The combo box is an intrinsic control. That means you don't have to specifically register any extra controls when you install the program.

The Package and Deployment Wizard should work fine. The installer it creates for your program self registers the controls it needs--which is not the current preferred method--but for the older VB6 programs, you sometimes have to self register the libraries, controls, etc. that you need to run the program anyway. You should run the installer created by the Package and Deployment Wizard on each machine you wish to use. It should register every component on each machine that you use.

If you want to use a more up to date installer, you can try the Microsoft Installer version 1.0 which is available as a free download from Microsoft: http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=105dfc41-801e-4441-aa75-7696d794f109&displaylang=en

But this involves somewhat of a learning curve. It's a nicer installer. It's database centered instead of script centered as in the Package and Deployment Wizard.

But really I need you to answer some questions: Are you connecting to a database (like Access) in this program? I suspect your problems stem from not having the proper database components registered.

hkdani 39 Posting Pro in Training

hi guyzz... is their a third party software were can i install/register all the vb dll files need in my visual basic project.

im having hard time in my installer setup. im using setup factory. and before im making the setup up factory wizard, im using the Package & Deployment Wizard of vb.

i have a lot of error. including the auto complete in combo box.

when im in my computer the autofill of data working fine, but in other computer i have a problem in auto complete. (dll files not included in vb.)

i thinking that if there is a third party software for all the list of vb dll, that can i download.

any one can help me.

thxx in advance

What Microsoft Data Access Components (MDAC) version does your program use? If you're using the 3.51 version of the Microsoft DAO library, then on an XP machine you have to install the MDAC_TYP.exe file, the 2.0 version. It's kind of hard to tell what your problem is, if you don't give the exact error message that pops up the machine that does not work.

hkdani 39 Posting Pro in Training

thanks for that il give it a try!
one more thing though how do i refer to each line ie the name line how does the program know which one it is there must be some kind of reference, thanks

In a flat file you just loop through the whole file or quit the loop depending on a search criteria.

How does the program know? The programmer has to have some idea of how the data is organized: usually it's by the first field in the line. For example:

1, George, Jungle, 1 800 MonkeyMan

1 would be the value of the first field. But the programmer has to extract this data by using code. Or he can use the Indexed Sequential Access Method (ISAM) drivers that come with the Microsoft Jet Database Engine and use the Microsoft Jet Database methods to work with the data. But I don't know what your instructor is requiring you to do. More than likely he would be content, if you just used a loop test like I have given.

But in designing databases you usually try to have at least one field with a unique ID. In this example, the first field would be a good field to use. You could use the phone number; but it would probably be easier to use the numbers.

But if you had 5 lines of data

1, george, ...
2, Jane, ...
3, Mike, ...
4, …

hkdani 39 Posting Pro in Training
arrayNumber = Left(strData, InStr(1, strData, "\") - 1)

Hope that makes sense

Well, you know, if you have to tell another programmer, I hope that it makes sense, you've got problems. Of course, that may depend on the programmer. But there's a simple formula for programming that should be followed: KISS.

I still can't make sense of that code. I still remember my old programming teacher telling me when I provided a very complex solution to a simple problem, "Keep it Simple Stupid!"

But this is what I'm guessing. You send a string: e.g. "1\some file data" You pull the number one with your code. That happens to be an integer. And I assume because there are only numbers before the "\" that you always extract integers in string form. And because the string can be converted by the compiler to a long, it doesn't throw an error.

In keeping with the paradigm of KISS--you did ask for tips for more robust code--I would simplify that code.

Private Sub SortNewData(ByVal StrSortcode As String, ByVal strData As String)
' Change that to the following

Private Sub SortNewData(ByVal StrSortcode As String, ByVal strData As String, MyArrayNumber as Long)

If you already know what the ArrayNumber is, why not just send it?
Add another parameter to your function. And then you wouldn't have to write extra code to extract the file data either. Just send the data as a string without any extra identifying characters. You could eliminate …

hkdani 39 Posting Pro in Training

Any suggestions on how to improve my code and make it more robust is extremly welcome

arrayNumber = Left(strData, InStr(1, strData, "\") - 1)

You're pulling an array number based on the position of the "\?"
I don't understand that. Explain, if you would.

And you declared arrayNumber as long and assign a string value to it? Why are you doing this? If you're using the Left() function (which returns a variant string value), you should be assigning its return value to a string variable?

I don't see how you dependably come up with a meaningful value number to use for your string array using this code.

hkdani 39 Posting Pro in Training

Hi Everybody,
I don't know how to embed this..
Could anybody help me please...
Thanks.

You're looking at using the OLEDB capabilities of VB. You should add a Microsoft Power Point Slide component into your project.

Go to the Project Menu and click on Components. Click on the Insertable Objects tab. Scroll down till you find the Microsoft Power Point Slide component. Check that. Of course, you need to have the Microsoft PowerPoint Slide program installed to have this component listed.

Once you do that you should see the PowerPoint Slide's component icon appear in your toolbox. You can drag that onto your form and you should have all the methods, properties, and events that you'll need to present your slide show from within your VB6 form.

hkdani 39 Posting Pro in Training

I didnt know that Visual Studio came with this kind of stuff.

The more you learn Visual Basic and other Visual Studio languages, the more you should realize that your most valuable ability is the ability to be able to search through the MSDN documentation and examples to find out how to do what you need to do.

There's too many functions, controls, and features to memorize them all.

hkdani 39 Posting Pro in Training

Any help / guidance will be appreciated

Well, this is a complicated request. And that on more than 1 level.

You have a couple of problems. Maybe three. First, you want to do this without being noticed. And you're asking to basically search a whole hard drive. This would require your user not to notice how long it takes while his program locks up waiting for your hidden code to search his drive. Read 5 to 10 minutes on modern large capacity hard drives. This would be fine, but really such a program should have its own execution thread so that the User could go on with his business while your hidden program goes about its business.

So, in reality you should write another program that could be called from a ShellExecute API in the Excel macro. And then you have the problem of sending the email information without the user noticing. This is not as difficult. And shouldn't take as long. You can use the MAPIMessages control to send a message without a visible interface.

But your third problem is one of legality. You're going about this the wrong way. If another individual is acting outside the law, use the appropriate authorities to prosecute the wrongdoer. Two wrongs do not make a right.

hkdani 39 Posting Pro in Training

In a flat file a comma, a space, or a tab is usually used to separate the fields in a record. You have one record per line.
So, your file--if indeed it is a flat file--should look something like this in Notepad:
1, George, Jungle, #02/05/07#, 800-Jungle
2, Jane, WildWoman, #02/05/08#, 1-800-ClimbATree
....

you can use spaces, tabs, colons, whatever to delimit fields.

But you should test every line as you read it for the data that you want to delete. I would use the Instr() function as tool to find the date that you wish to delete. But your program first has to save the search criteria to use it in your code. Just load the ID of the record that you want to delete into a variable: I'll leave that to you.
And use that variable in your Instr function.

Dim LinesFromFile as String, NextLine as String
Dim strTest as String, strId as String, strDelimiter as string
Dim strExtracted as String 
Dim lngDelimiterPosition as long

strDelimiter = ","

Do Until EOF(FileNum)
   Line Input #FileNum, NextLine
  ' 
  lngDelimiterPosition = Instr(1, NextLine, strDelimiter, vbTextCompare)
  ' Isolate just the ID
  strExtracted = left(NextLine, lngDelimiterPosition - 1)
   if strID <> strExtracted then 
        LinesFromFile = LinesFromFile + NextLine + Chr(13) + Chr(10)
   End if
Loop

This will read every line in the file. But you probably have no other choice. But being that it's at least a Pentium class machine. This would probably take less …

hkdani 39 Posting Pro in Training

I read through that tutorial, and its not quite what I need.

I think the best examples are found in the VISDATA program that comes with the MSDN CD's. If you installed the full installation, you should be able to load this sample project with the code from this location: C:\Program Files\Microsoft Visual Studio\MSDN98\98VSa\1033\SAMPLES\VB98\visdata

This program gives example code on importing and exporting data to and from excel files along with a host of other database tasks.

hkdani 39 Posting Pro in Training

I would prefer to have the feature to be able to save the table as an excel sheet or a table in Wordpad.

Tamir:

Just convert your data to an excel format. To do this you need to have installed the Indexed Sequential Access Methods (ISAM) during the setup of Visual Basic. If you could give a small sample of the data that you want to save that would help. And if you could be clear as to your final goal?

Do you just want the data to be saved as An Excel Compatible file so that you reload it later with Excel?

hkdani 39 Posting Pro in Training

http://msdn.microsoft.com/en-us/library/aa733652(VS.60).aspx
The above was just my meager attempt to get you started. You need to use the report format. The MSDN link above should give you the information you need to accomplish your task.

Hank

hkdani 39 Posting Pro in Training

Basically I am struggling with the code to display the records on ListView from the Database. Can anyone please give me some hints.

Basically you just use the Add method of list view Listview.listItems.Add Index, Key, Text, Icon, SmallIcon as ListItem If you're using a database recordset, you might try using a loop with the EOF property.

With MyDatabase
     .MoveFirst
     while Not .EOF
         ListView1.ListItems.Add , , .Fields("MyFoundField")
         .MoveNext
      Wend
End with

I don't use these listviews much; but I think that the Columns property is intended to design the listview on the fiy. If you want to add items, I would say to use the ListItems Method.

hkdani 39 Posting Pro in Training

Ok. You need help. You're stuck on this error. Ok. But what is the error you're stuck on. You failed to mention the error.

hkdani 39 Posting Pro in Training

Use the Text Change event provided by the textbox control

Private Sub Text1_Change()

End sub

I won't write your code for you. But you should check the position of the current letter. Since the text change event is fired every time you enter a different letter or change a letter, this shouldn't be a problem.

Positions you will have to test for:
(1) If the Current Letter is the first letter

(2) if the current letter is after a space.

You could use the len() function and the mid$() function to achieve your goals.

Hank

hkdani 39 Posting Pro in Training

Is there a way in which this can be automated via vb 6.0?

I would look at your situation and determine where the variables will occur in making your data source. If the only thing that is changing is the address of your data source, then you should have a menu item or some other means of allowing the user to set the address of the data source. You could store that information in the registry using the SaveSetting function: e.g. SaveSetting "MyProgram", "Data", "DataAddress", strSetting

You should use some kind of error checking to ensure that the user entered a properly formed string.

Private Sub RegisterDataSource()
Dim en As rdoEnvironment
Dim cnTest As rdoConnection
Dim strAttribs As String
Dim strAddress As String

' Build keywords string.
strAttribs = "Description=" _
        & "SQL Server on server SEQUEL" _
  & Chr$(13) & "OemToAnsi=No" _
  & Chr$(13) & "SERVER=SEQUEL" _
  & Chr$(13) & "Network=DBNMPNTW" _
  & Chr$(13) & "Database=WorkDB" 
  
strAddress = GetSetting("MyProgram", "Data", "DataAddress", "NotEntered")
if strAddress = "NotEntered" then
     msgbox "Please enter Data Address Information before making connection", vbCritical, "Data Address needed"
Else
     strAttribs = strAttribs & Chr$(13) & strAddress
End if
' Create new registered DSN.
rdoEngine.rdoRegisterDataSource "Example", _
         "SQL Server", True, strAttribs
' Open the database.
Set en = rdoEngine.rdoEnvironments(0)
Set cnTest = en.OpenConnection( _
  dsname:="Example", _
  Prompt:=rdDriverNoPrompt, _
  Connect:="UID=;PWD=;")
  

End Sub
hkdani 39 Posting Pro in Training

Please tell me how can i remove "Invalid use of null" problem . Coding given below

Private Sub
On Error goto ErrorFix
' Code
....
....
'
Exit sub
ErrorFix:
Select case err.Number
case 13 ' Invalid use of null
     resume next
case else
     msgbox err.description & " Error #: " & err.Number, vbinformation, "Error"
     resume next
End Select
'
End sub
hkdani 39 Posting Pro in Training

Dear Friends,
I got two problem related to Data Report.
1. I got more than 20 temporary file with extention .tmp in my project folder.

2. My report unable to show effect after deletion of any record. It only takes effect when i
close the program and then restart program.

If you have some procedure than please tell me

I wouldn't worry about the tmp files. If you have any concerns, when you're done with the project you can manually erase them.

I assume you're updating your records right before you do your report? And that you're using ADODB with Access as your database type?

You should see the changes reflected in your data report immediately after updating your database files. The only reason that I can think you're not seeing the changes would be that you already have the data report loaded but not shown. So, the report has already loaded its data.

But I guess I would need the following information to help you: (1) When is your data report loaded? and (2) some of your code showing what you're doing to update your database files.

hkdani 39 Posting Pro in Training

It still seems to me that if I have opened a connection from my project to an associated database that there should be some way of using that connection across all the forms in that project.(Surely there is a logical way of transferring the properties of the objects involved across the board)

Class Modules are the way to go, I would say.

You'll notice that Class Modules have a Data Source and a Data Binding Property.

You write the code to initialize the ADO Database objects and to terminate or close them in the class module.

You can then access this class module from anywhere in your project. Usually, in a form.

Option Explicit
Dim MyCounter as cmCounter


Private Sub Form_Load
set MyCounter = new cmCounter
'
'
End sub


Private Sub Form_Unload
' Close out your class module
set MyCounter = nothing

End sub

Check out the MSDN documentation, if you have the CD's Look for the section Accessing Data Using Visual Basic under the Data Access Guide.

Using Visual Basic/Data Access Guide/Accessing Data Using Visual Basic

Hank

hkdani 39 Posting Pro in Training

You should try using the form name first when using it from form2: e.g.
form1.MyRs

It's best to use class modules instead of regular modules. Class modules have better support for Data Objects.

Hank

hkdani 39 Posting Pro in Training

BUT another BUT.. do you know y it work?? and why does my 1st query wrong???

It might be the single quotation marks. Try it with and without them.

Hank

hkdani 39 Posting Pro in Training

Is there anyother to achieve this

You can remove the quotes using if statements before you insert the string into the SEQUEL statement:

Dim strInsert as String
Dim intLength as integer

if Mid(strInsert, 1,1) = "'" then
  strInsert = right(strInsert, len(strInsert) -1)
end if

intLength = len(strInsert)

if Mid(strInsert, intLength, 1) = "'" then
  strInsert = Left(strInsert, intLength -1)
Endif

Hank

hkdani 39 Posting Pro in Training

Module Main

Public EmployeeID as Integer

Form1

Private Sub Command1_Click
  EmployeeID = rs.Employees("EmployeeID")
  Unload Me
  form2.show
End sub

Some good advice by debassidas. But that should get you started.

Hank

hkdani 39 Posting Pro in Training

You should add a Microsoft ADODC data control component.

In the properties of that control, you need to set the Connection String, the Command Type, and the Record Source.

After you do this, then you need to set the Data Source Property of the Microsoft Data Grid Control. And that should be it.

Hank

hkdani 39 Posting Pro in Training

This application has failed to start because MSVBVM50.DLL was not found.

I can't remember back that far:VB5.
But if there's a Package and Deployment Wizard, package your application into an installer using it and install the program using the Package and Deployment Wizard. That should take care of your dependencies.

If MSVBVM50.DLL is the only DLL you need to install, you can just copy it to the Windows\sytem32 directory. Go to a command prompt and changed to that directory. And then enter the following at the prompt:

c:\Windows\System32>regsvr32 MSVBVM50.dll

That should solve your problem with that one file. But you might find others after you fix this one.

Hank

hkdani 39 Posting Pro in Training

I need to click on an individual bar to get it's index value. All I can
get is value for the first bar on the chart.

The Microsoft Chart Control doesn't really fit your goals. It's more for a visual representation of data: not for a response to user intervention.

The Index property which you mentioned is for an array of charts with the same name on the form.

You might, however, devise a way to do what you want by calculating the coordinates on the form and coordinating that with the Current Mouse Position relative to your form.

If you can calculate the exact position of the bars, then you can determine which bar is clicked by using the CurrentX and CurrentY positions of a mouse click.

Hank

hkdani 39 Posting Pro in Training

dim objForm as form
dim sValue as string

sValue="frmXXX"

set objForm=sValue
objForm.show

This is what the code looks like... i need to convert the variable string to form object

thanks a lot.

If you already have the forms made, that really shouldn't be a problem. Use a Select CASE statement.

Dim strFormName as String

Select strFormName

Case "formXXX"
     formXXX.show
Case "FormX1"
     FormX1.show
Case "FormX2"
     FormX2.show
End Select
hkdani 39 Posting Pro in Training

have to connect a thumb imression device with my project

What's the name of the device and model number?

hkdani 39 Posting Pro in Training

("SELECT * from tblLecture where arlNumber = '" & lblLECNUM & "' ")

SELECT * from tblLecture WHERE alrNumber=" & cstr(lblLECNUM)

Don't think that will make much difference. But it's a little clearer.

there's my code, im having a error "DATA TYPE MISMATCH IN CRITERIA EXPRESSION "
but i cnt and no idea where it is.... and im still finding it

That particular error usually pops up when you have a NULL value coming from your form. Try using an error checking code before you run the SEQUEL statement.

If lblLECNUM.Caption <> vbNullString then
    ' Execute Code for Database
Else
    ' Do not execute Code for Database
Endif
hawisme000 commented: thx for helping =) +1
hkdani 39 Posting Pro in Training

Set mydb1 = OpenDatabase(App.Path & "\parlordb.mdb")
Set myrs1 = mydb1.OpenRecordset("parlordb")

myrs1.Open ("select * from parlordb where custname=searchname")

Your mistake is in your syntax. You have a variable inside a quotation mark.

myrs1.Open("Select * from parlordb where custname=" & searchname)
hkdani 39 Posting Pro in Training

Set the border style of the window to fixed Single.

hkdani 39 Posting Pro in Training

If CtDn < -1000 Then 'bit of faff to avoid over midnight countdown
CtDn = CtDn + 8640000
Else

Use the datediff function to avoid midnight problems.

hkdani 39 Posting Pro in Training

Everything else is just algebra and logic.

You need to have one established reference point: That's the value you derive from using the above API's and finding the current time using the Now function.

Lets' call that value lngValueA. Save that value and use it as a reference point for your minutes:seconds:milleseconds.

Once you have established that reference point. You need to come up with a formula to calculate How many minutes, how many seconds, and how many fractional seconds.

This is just basic algebra.

hkdani 39 Posting Pro in Training

its starting from a number like 1774796

It always helps to read the manual. In this case: the documentation which is freely available online from MSDN for this API.

how can i make it actually count down and start from 8 minutes??

http://support.microsoft.com/kb/172338

hkdani 39 Posting Pro in Training

Just to finish up. Most of your Visual Basic Controls are for the most part built from the Win32 API's from the Platform Software Development Kit, which are built using the C/C++ Languages.

I personally don't feel, because of the current vast multitude of hardware that depends on serial communications, that Microsoft will eliminate the Serial Communications API's in their releases of the SKD's for another 10 or 15 years by placing them in the obsolete category.

But it might be a good time to start thinking about implementing USB hardware into the picture.

hkdani 39 Posting Pro in Training

This code, when the timer property for interval is set at 1 millisecond, should give you resolution of the user's system timer.

This came out to be about 15 milliseconds on a 2.4 GHz pentium4

Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim blnStart As Boolean

Private Sub Command1_Click()
   Timer1.Enabled = Not Timer1.Enabled
End Sub

Private Sub Form_Load()
   On Error GoTo Load_ERROR
   blnStart = True
   Exit Sub
Load_ERROR:
   MsgBox Err.Description, vbInformation, "eRROR"
End Sub

Private Sub Timer1_Timer()
Static CurrentTickCount As Long
Dim lngTickCount As Long, lngDifference As Long
If blnStart = True Then
   lngTickCount = GetTickCount
   CurrentTickCount = 0
   blnStart = False
Else
   lngTickCount = GetTickCount
End If
If CurrentTickCount = lngTickCount Then
   
   CurrentTickCount = lngTickCount
   lngTickCount = 0
Else
   Label1.Caption = lngTickCount
   lngDifference = lngTickCount - CurrentTickCount
   Debug.Print lngDifference
   CurrentTickCount = lngTickCount
End If

End Sub
hkdani 39 Posting Pro in Training

This API function Return a time in miliSecond for each time called.
you can use it.

That API depends on the resolution of of the operating system's timer.
That could be anywhere from 9 to 100 milliseconds.

If the user requires a resolution of 1 millisecond, then you'll have to use the other API's to determine if the running CPU has that capability: hence the necessity of using the QueryPerformanceFrequency and QueryPerformanceCounter APIs.

hkdani 39 Posting Pro in Training

Can you please expand a bit on your VB6 comment, specifically on how VB6 serial comms commands available are much better than QB45's?

You just have to look at all the different properties supported by the serial port in VB6.

Quick Basic is really basic. You have to know how to access the lower levels of memory addresses to extract information from its ONCOM event. In VB6 this is greatly simplified. You can respond to feedback in the events with a wealth of properties already supplied by VB6. You can send as text, binary. You can set how many characters to receive at a shot, etc. I'm not too familiar with what Quick Basic 4.5 can do. I've done most of my serial hardware programming in VB6.

I'm assuming that your hardware doesn't give feedback over the serial port. And hence no need to respond.

I'm guessing from what you've already mentioned that you just have a few basic commands to give to the hardware and it responds and performs the desired action without responding back to the serial port?

In either case, VB6 should handle what you need to do. As long as you have the manual that states what happens when a binary code is sent to your hardware (or what binary code is sent back, if it provides feedback). The rest is just a matter of writing the VB6 code to handle what your desired goals are.

(I believe they were using …

hkdani 39 Posting Pro in Training

You need to set the Cancel Property of the the Common Dialog Control to True. If you do this, then an error will be generated with a value of 32755 whenever the user clicks on cancel.

Just set up error checking code

Private Sub Command_Click()
   On error goto Click_ERROR



   exit sub
Click_ERROR:
  If err.number = 32755
      ' Enter code to do whatever you want
  Else
      ' Do whatever
  End if

End Sub

SCBW had a good post. But this is just another way to deal with the problem. Make sure you enable the cancel error property.

CommonDialog1.CancelError = True

That's the main point. Set that. Then deal with the error code.

Hank

hkdani 39 Posting Pro in Training

So what is the prognosis of being able to run VB6 in the future with Microsoft playing so many games on the operating system side

Microsoft has commited to supporting VB6 for the next 5 - 6 years. But that's in reference to Vista. AFter Vista, I imagine VB6 is out the window.

As long as you have your copy of XP Pro and a 32 or 64 bit working machine, you should still be in business. Vb6 will work on XP Pro as long as you keep your machine running.

Does VB6 directly support full control over what goes in/out of the serial ports on an XP-pro PC (like the old QB45 ON COM, OPEN COM, INPUT #1 etc.)?

VB6 has better support than .Net 2003 for serial support. And much better than Quick Basic.

Is it a straight forward job

Couldn't really tell you that unless I saw the code. I don't know if you have all the pieces of the puzzle. I take it you're dealing with hardware that measures thickness. This hardware has to have some kind of manual that gives you the specifications on how it responds to serial communications. We call that a Software Development Kit (SDK ). If that's not available, the porter would be on his own trying to figure out the intentions of the original programmer.

That would be your main concern.

Hank

hkdani 39 Posting Pro in Training

What is the best path forward...

That should be doable. It would take some work and patience. But with a methodical approach, you could have a much better GUI based program developed from VB6 or VB .NET on an Intel Architecture Machine (32 bit or 64 bit processor).

The biggest problem with these types of projects is that the original programmer must have been a hater of self documentation in his program code--that's not a too uncommon trait in programmers. Get it to work. Who cares about the documentation.

Easy to say then. But now after $350,000.00, it's kind of hard to swallow by the customer.

Hank

hkdani 39 Posting Pro in Training

(rs!Titles(Where(rs!Teacher = teachers.Text)))

You've put the cart before the horse.

Your first step is to open the recordset using a sequel statement string: rs.open ( source, etc., , , )

Your sequel statement will go in the source parameter as a string

Dim strSequel as string

strSequel = "SELECT Titles.Teacher from Titles WHERE Teacher='" & teachers.text & "'"

rs.Open strSequel, etc. , , ,

I'm taking for granted the name of the table in your recordset is Titles and the Field you are searching is Teacher.

A good download for you would be the Microsoft Active X data objects Software Development Kit (SDK). The current release is at 2.8. It has a very well written manual which give examples on how to open up databases.

Once you open the database using the above sequel string, you should have a recordset of Titles where the Teacher is the name you have entered in the teachers text box control.

I could just give you the code in a zip file. But I think you would benefit more in the long run by downloading the SDK, reading the documentation. But if you get stuck, let us know.

Hank

hkdani 39 Posting Pro in Training

i know how to make a simple timer with seconds. but how to put minutes n milliseconds?? it should look like this
minutes:seconds:milliseconds

Using the 'Now' function with VB6 (this is a VB6 forum) gives you the current time. However, this will only give you the time in seconds.

Even if you convert the Now to a double precision value (which you'll have to use obtain milleseconds), the best you will get is still a change in the visible value every second.


So what you need to use is the Windows API 'QueryPerformanceCounter' in your program to obtain a higher precision of accuracy. To find how much precision your CPU will provide you use the 'QueryPerformanceFrequency' API

The degree of precision depends on your CPU and how simple you can keep your code.

Private Type LARGE_INTEGER
    LowPart As Long
    HighPart As Long
End Type

Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As LARGE_INTEGER) As Long

Private Declare Function 

QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LARGE_INTEGER) As Long

Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LARGE_INTEGER) As Long

I've given you a start. But here's the pseudo logic you'll need:

Determine your CPU's capabilities with the QueryPerformanceFrequency

Create a loop to provide a value to use for your millisecond display.

And you need to provide some method to get yourself out of the loop.

I'll leave the rest to you. But that should get you started.

Hank

hkdani 39 Posting Pro in Training

Clarification needed.

Is that what you meant?

How do you forbid size modification of the window?