hkdani 39 Posting Pro in Training

You just need to build a string to enter in the first parametere of the Visual Basic Shell function.

If you have two text boxes, and the user has entered the appropriate numbers, just use the entered values to build your string for the first parameter of the Shell function.

lngReturn = Shell("c:\cfiles\cfile.exe " & txtNo1.text & " " & txtNo2.text, vbNormalFocus)

Your C++ program should be able to handle the arguments using GetCommandLine(), if using the GUI or argv[] if using a console application.

AndreRet commented: Nice answer. +12
hkdani 39 Posting Pro in Training

First of all, you're to be commended for following the guidelines and submitting your code along with the request. The ability to follow instructions is a good indicator of future success!

when the input is 12 years and 6 months I want the program to print teenager
I'm not sure how to do that

BitBlt has a good suggesting of converting the test to a numeric value. You should do the same with the months value.
Use an if statement:

if (months = 6)
     Printer.print "teenager"
End If

and whenever I leave the months text box empty I need the program to just read the year without crashing

Use a test before submitting the value to your select case structure: if txtMonths.text = vbnullString then txtMonths.text = 0

hkdani 39 Posting Pro in Training

How i can split a sentences into words and add splitted words into listbox.

You could try writing some code as is suggested for submitting requests in the guidelines.

But you could use the Mid function as indicated or you could use the Instr function. Search for the space character and declare a variable to return the value returned from your search. You'll use that value to start determine the word and also to determine the start point for the remaining portion of your search.

hkdani 39 Posting Pro in Training

rs.Open "Select * from tblpos where category like '" & cbocategory.Text & "' and date between '" & DTPicker1.Value & "' and '" & DTPicker2.Value & "';", cn, adOpenKeyset, adLockOptimistic

This is what I meant: Instead of using "' use """. You need to start using a SQL Designer and testing your sequel statements before using them. The data environment with VB6 has one and Microsoft Access has its own sequel designer. But you should make sure that your sequel statements actually work before plugging them into your code.

Also, I can't really tell where the ELSE statement where the error occurs. You have line numbers on your post for your code. Mention the specific line number. It's helpful to add error checking code that includes at least the following:

  1. err.Source 'The error source
  2. err.Description 'The error description
  3. err.Number 'The error number

If you could provide these three things it would be easier to pinpoint the error.

rs.Open "Select * from tblpos where category like '" & cbocategory.Text & "' and date between """ & DTPicker1.Value & """ and """ & DTPicker2.Value & """;", cn, adOpenKeyset, adLockOptimistic
hkdani 39 Posting Pro in Training

That error just means that the Type WAVEHDR has not been previously defined or declared in the VB6 environment by the user.

WAVEHDR could be anything the user wants to declare it as, for example:

Private Type WAVEHDR
     intWaveLength as Integer
     dtChanged as Date
     dtCreated as Date
     WaveName as String
End Type
hkdani 39 Posting Pro in Training

You're certainly welcome. I knew you could do it.

hkdani 39 Posting Pro in Training

Yes, but you'll avoid problems with VB6 if you use the Option Explicit Option. This forces you to declare your variables as a certain type: e.g. integer, single. double, string, date, etc.

Following this practice can save you a lot of headaches down the road.

If you don't use Option Explicit, then if you declare a variable it will be used as what is called a Variant variable. This means you can use this variable for numbers, characters, strings, floating point values, whatever.

You use Option Explicit at the top of the form when you first start a program. Or you can set it in the Tools Menu under the Options SubMenu item.

Check the box that says: Require Variable Declaration.

The program will then complain that you haven't declare a variable as a certain type. But I stress, you must do this when you first start. If you start and then change it later, the program will just ignore the Option Explicit.

Here's a few spelling corrections:

Tuesday --> Not Tusday
Thursday ..> not Thirsday
Saturday --> not Saterday

hkdani 39 Posting Pro in Training
Dim lngReturn As Long
lngReturn = Shell("c:\MyProgams\cfile.exe", vbNormalFocus)
hkdani 39 Posting Pro in Training

I told you there were errors in the code. I left them in there. And you found one. Now you need to fix it. I don't mind helping you. But I just felt that your friend should do some of the work. Nevertheless, WaltP has graciously pointed out the error for you in line 28 which is listed quite clearly in a previous post as the following (see line 28 in previous post): Line Input #lngFileEngland, strArray(intCounter) By the way, did I say that was line 28?

I threw away the code here. Don't need it. But what I had originally considered was storing each line in an array of string: Dim strArray(7) as String. That way you could save each line in the array for future reference within the function. But after seeing the code in action, I determined I didn't need an array. So I removed the array changing strArray(7) to just strArray. Hence, the error I knew would arise, if you tried to run the code as is. Apparently, not only does your friend in Sweden have VB6, you must have Visual Basic also.

At first the original code contained a fixed array of strings ( strArray(7) ) that would hold the days of the week as they were being loaded inside the Do Loop. Since VB6 arrays are by default zero based--meaning the first index starts with 0--this will actually give you 8 days. So, technically you could use strArray(6) and have 7 String …

hkdani 39 Posting Pro in Training

Here's some sample code. Return the favor someday.

There are some errors in the code. And code for what to do for Greece has not been included. Your friend will have to find the errors and fix them. And he will have to do some thinking about how to deal with the day in Greece.

But this should help y'all out.

Option Explicit
Dim strNameEngland As String, lngFileEngland As Long, strLeneng As Long ' för England
Dim strToday As String
Dim lngStrLength As Long

' strtoday = Format, "dddd") ', "d")


'Do Until EOF(Fnumeng)
'
'Line Input #Fnumeng, namneng
'
'If Left$(namneng, 1) = today Then
'
'strLen = Len(namneng)
'
'Label2.Caption = Right$(namneng, strLen - 6)

Private Sub cmdOpenFile_Click()
    Dim strArray As String
    Dim strTemp As String
    Dim intCounter As Integer, intDate As Integer, intFileDate As Integer
    intDate = Weekday(Date, vbMonday)
    lngFileEngland = FreeFile
    Open App.Path & "\Dani.txt" For Input As #lngFileEngland
    
    Do Until EOF(lngFileEngland)
        Line Input #lngFileEngland, strArray(intCounter)
        
        intFileDate = CInt(Left$(strArray(intCounter), 2))
        
        If intFileDate = intDate Then
            lngStrLength = Len(strArray(intCounter))
            lblDate.Caption = Right$(strArray(intCounter), lngStrLength - 2)
            Exit Do
        End If
        
        intCounter = intCounter + 1
        
    Loop
 
    
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Close #lngFileEngland
End Sub
hkdani 39 Posting Pro in Training

the error appear on the line rs.open in my else condition...why?

Well, now we're getting somewhere. That helps.

"Select * from tblpos where category like '" & cbocategory.Text & "' and date between '" & DTPicker1.Value & "' and '" & DTPicker2.Value & "';", cn, adOpenKeyset, adLockOptimistic

I see you're using single quotation marks '

Try using double quotation marks. I've had trouble with that before. Using double quotation marks seems to do the trick.

Working with dates in SQL statements connecting to databases is kind of tricky. Sometimes it helps to stick them in a SQL Designer and test them to see if your SQL statements are actually working.

hkdani 39 Posting Pro in Training

No, you don't understand.
You've already defined a struct at the beginning. You need to declare an array to the struct you've declared.

struct word_length MyWord[MONTHS] ; 
// And then you need to fill in the values in your for loop
MyWord->word = "January" ;
MyWord->count = strlen("January") ;

This is just one way to do what you want. There are other ways. You should read up on how to declare structs and how to use them. Based on the posts you've been listing here, you haven't done your homework. And that is My Word for the day

You can use your way. But I believe your instructor wants you to use the strlen function. You're not doing that. What is the length of "January"? It's certainly not 0. Be sure to read your instructor's instructions carefully. Otherwise, everything may come out correctly. But since you have not been careful to follow instructions, you may not get the grade you want.

You need to fill in the values in the manner he requests.

Then within for-loop, find the length of each month using strlen from string library,
and update the array.

I don't believe you will pass this part of the assignment.

hkdani 39 Posting Pro in Training

You don't need to initialize the array at first.

But you should define an array after

int main(void) // use void, don't leave it blank
// declare your array to your previously defined struct here.
// I'm not going to do it for you.
int i ;

for (i = 0; i <12; i++)
{
     // Fill in the values for your *struct here.
}

That should get you going along the right direction. If I would do more, I should probably sign up for your class and receive credit.

minimi commented: Thank you! +2
hkdani 39 Posting Pro in Training

First of all, it would help for readability to use what are universally accepted variable declarations for variables.

For example, use str at the beginning of a string variable, int at the beginning of an integer, lng at the beginning of a long variable, etc.

strDateGreece as String ' as opposed to iDag as string
lngStrLength as long ' as opposed to strLenEng as long

Experienced programers used to accepted standards could easily mistake your variables for the wrong type.

See if your friend could rewrite this. Then we'll take a closer look at it.

hkdani 39 Posting Pro in Training

I see you have a .ListSubItems But where are you declaring a ListItem. I don't see that in your code.

Dim si as ListItem
hkdani 39 Posting Pro in Training

will u please make it more clear "virtual memory" "heap"..? please.?

Virtual memory. Memory from the hard drive simulated to run as Random Access Memory (RAM) when your computer runs out of RAM resources. Your system will thrash when using the swap memory or virtual memory. Performance will slow down.

The heap is just a generic term referring to the available Random Access Memory. You might want to a Google search using the two words HEAP and STACK.

hkdani 39 Posting Pro in Training

You can still use the LoadResString function. It does not have to be used just when the user changes his locale.

But you'll just have to add more items in the resource table.

Use

LoadResString(128) for Swedish.
LoadResString(256) for English

And you'll have to some method for the user to toggle his preference. And then you need to write code to change the captions or pictures or whatever it is that you want to change.

You can write a private function in your form to accomplish the same:

Private Sub LoadResourceStrings(ByVal CountryID as Long) 

' Enter code here to change captions based on CountryID

End Sub
hkdani 39 Posting Pro in Training

You should use the International Friendly functions supplied with VB6. This must be a classroom assignment. You're not the first to post here about how to do this.

Look up the following phrase in yous MSDN documentation: "Writing International Code in Visual Basic"

But never use a string value for a date. Use the date format: #8/2/97# And you should get used to using the resource editor which is designed and supplied by Microsoft to deal with International issues:

Use the LoadResString(ByVal TagID as Long) as String function to load different values based on the locale your user has set in the Control Panel for his country. Your program will then detect the user's system's locale and use the appropriate Resource String based on the country settings of the operating system.

You'll need to load the Resource Editor Addin in your IDE. And then you need to one string table for each country you wish to support. And then when your program loads, use the LoadResString function to load the correct string value: e.g. Label1.Caption = LoadResString(cLng(Label1.Tag)) .

hkdani 39 Posting Pro in Training

You could add an Edit Menu to your program with a Preferences Menu Item. You could use that to toggle the buttons on your form with the checked value of the menu item.

Edit>Preferences>English.


In the code you would then change the properties to make them enabled or disabled based on the checked state of the menu item. You can change the visible property of a button to make it appear or disappear.


For a quicker, easier, and a more visible solution to the end user, you could add a toolbar with an imagelist and use images of the national flags to toggle the addition or removal of the other buttons. One button with an American or British Flag and the other button with an image of the French Flag.

If you want to add different language characters to a button and they will not show up, you can set the style property of the button to Graphical. And then use a Picture with the desired letter for the Picture property of the button.

hkdani 39 Posting Pro in Training

Use a select case statement and an array of command buttons called something say cmdBtnProp.

So you should have cmdBtnProp(0), cmdBtnProp(1), etc....

Then whenever the user clicks on one of the buttons, it will point to the same section of code. At this time, you'll use the Select Case mechanism to determine which button was pressed

Select Case Index

Case 0

Case 1

Case 2

Case 3

Case Else

End Select

Write the appropriate code inside of each case statement. That's one way. That should get you started.

hkdani 39 Posting Pro in Training

International settings can be changed in VB6 by the end user by changing the locale settings in the control panel.

In VB6 you should be careful to use international friendly code so that this can be done, for example: format(curAmount, "currency") The code will search the user's locale settings set by him in control panel for the local currency and use those settings for setting the currency symbol and the decimal point. Some countries use a dollar sign, some a pound sign. Some use a comma for a decimal point, some use a period, etc.

Thus, if your code is international friendly, you won't have to worry about writing special code for each country. International friendly functions are already built into the programming language, you just have to use them.

The same applies for formatting for time: format(dateTime, "longtime") If you use the resource editor in VB6, you can have your program load different values for the captions based on the locale settings set by the user in Control Panel.

Then instead of using the properties for caption directly to load a caption for a control, you use the tag property of the control to store a numeric value which will be used by the LoadResString() function:

Private Sub Form_Load()
    ' LoadResString(ByValID as long) as String
    Form1.Caption = LoadResString(CLng(Form1.Tag))
End Sub

Loading Menus and some other controls is different. You'll have to stick the numeric value in the caption or another property area. But one …

hkdani 39 Posting Pro in Training

wat is the every possible difference between sizeof(node*); and sizeof(node);

Any variable using the * operator means that it contains the memory address of a variable.

What is important to know is that your memory has been set aside by malloc insuring that a process or thread is accessing dynamic memory or RAM. malloc needs to know how much memory to set aside. And since variables come in different byte sizes, you must tell it which type of variable to use with the sizeof function. Using the sizeof function on an address (node*) will not tell you what size needs to be allocated for the variable node: sizeof(node).

Your program will be using a thread or process that needs to know what's inside the variable node. It will know the address, but if it has to kludge through virtual memory to find the information it needs, then your program will not operate at peak efficiency.

So, the real question is not what is the difference. But what is the reason. What is the reason for using node instead of node*.

I don't know why you're looking for differences. An address is an address. A variable is a variable. It's kind of basic. Don't make it more difficult than what it is. Wrapping your head around the meaning of pointers in C is sometimes a process that takes a few months or even a year or so for some.

hkdani 39 Posting Pro in Training

node
1. In local area networks, a device that is connected to the network and is capable of communicating with other network devices. 2. In tree structures, a location on the tree that can have links to one or more nodes below it. Some authors make a distinction between node and element, with an element being a given data type and a node comprising one or more elements as well as any supporting data structures. (MSDN)

So, you are declaring the contents of new1 to be equal to what memory is allocated for the size of the address of a node pointer variable.

the contents of new1 is allocated for the size of the address of a pointer to node
*new1 -----------------= ---- malloc ------- sizeof -------------(node*)

Many times the purpose of allocating memory on the heap is so that all memory transactions take place on the physical random access memory (RAM) of the system instead of being possibly swapped out with virtual memory; i.e the slower memory on the hard drive. This could greatly slow down a thread or a process. So, if your process or thread is constantly accessing node new1, you don't want it using virtual memory.

hkdani 39 Posting Pro in Training

You want to use the malloc function to allocate memory on the heap for the size that a variable, array, etc. will occupy.

One way the * operator can be explained is by saying "the contents of" in its place.

So, your first example makes sense: the contents of new1 = malloc(sizeof(node))

In other words, malloc is allocating the size in bytes that node will hold in memory for the contents of new1.

A variable or an object takes up a certain amount of space or bytes in memory: a byte variable would take up more space than a long variable.

A pointer variable contains an address to a location. It holds the value of an address.

Think of a pointer variable as the address on the house: say 123.

malloc's intent is to allocate memory for what's inside the house at 123, not for allocating memory for the address on the house.

That's what you're doing in the second example: allocating memory for the address instead of what's inside the house at 123. That's not the intended use of malloc.

hkdani 39 Posting Pro in Training

The Combo Box has a Click Event. When a value in the Combo List Box is clicked, it raises the Combo_Click() Event. Select the Combo1 Control from the Control List box on the left hand side of the IDE. And then click on the Combo_Click Event. That should set code for the Click Event in the IDE editor.

Within that Click Event Write code to Add the contents of the currently selected item into the list box. The action of clicking on the Combo Box should set the current selection to the value you want to transfer to the List Box. The ListBox has an add function which you should use to add the value of the combo box to the list box.

You should be able to figure it out from there.

hkdani 39 Posting Pro in Training

Just use the ASCII values Chart for the characters. I don't know why you're using all those Mod functions? ASCII values for the UpperCase letters run from 64- 90, lowercase from 97 - 122.

You'll have to write code to deal with any shifts that throw you over the limits (90 or 122). But you can add 2 directly to the value of the Ascii Value to obtain the shift value.

For instance the ASCII value of 'a' is 97. Add 2 it would be 99. chr$(99) would be 'c'
There are UCase and LCase functions to convert Upper to Lower and Lower to Upper case.

hkdani 39 Posting Pro in Training

Use fflush after your scanf or gets lines.

printf ("Enter the number of student >> ");
    scanf ("%d", &n);
    fflush(stdin) ;

..........

fgets (name[i], sizeof(name[i]), stdin);
	fflush(stdin) ;

..........
fgets (name[i], sizeof(add[i]), stdin);
	fflush(stdin) ;

You're getting unwanted characters from a previous function's return value.
fgets is preferred over gets. gets has security issues. fgets forces the limit on the size of the input(the second parameter). The first parameter is the destination, the second the limiting size, third parameter is the source. gets has no limiting size and could potentially overwrite memory.

hkdani 39 Posting Pro in Training

use fgets or gets over scanf: it's safe and secure. scanf terminates when it finds a whitespace character. A space is a whitespace character. So, Diwakar wagle gave a good suggestion to use fgets. These two functions will include the spaces and terminate when receiving the newline character '\n' or when you hit the enter key. gets will remove the '\n' character so you don't have to. fgets will include the '\n' character.
If you want your program to advance a new line without using printf("\n") ; use fgets.

#include <stdio.h>

int main(void)
{
   char string[80];

   printf("Input a string:");
   gets(string);
   printf("The string input was: %s\n", string);
   return 0;
}
hkdani 39 Posting Pro in Training

lines 30, 32

You are providing one character not a string name[i][30] . Use only the leftmost index to access the whole array of characters for the row as Ancient Dragon pointed out: string name[i] .

You don't need to use the fflush. Just keep it simple.

My bad, use the & operator.

hkdani 39 Posting Pro in Training

More than likely your program is crashing because you are asking scanf to enter a string when you only give it one character: scanf ("%s", &name[i][30]); . You must supply scanf with an array of characters: e.g. scanf ("%s", &name[i]); What you have declared char name[30][30] ; char add[30][30] is a pair of two dimensional character arrays: one two dimensional array of characters for the name and another for the address. The effect of the declaration is to allow you 30 names each with a character limit of 30 and 30 addresses each with a character limit of 30.

In a two dimensional array the rightmost value would correspond to the columns and the leftmost value would correspond to the row. In this situation, the leftmost value would indicate the name or the address: e.g., name , add.

If you use both values you are only referencing one of the values inside the row. In your case, just the last character of the row.

But a string is an array of characters; so, you must reference the row and not just the one column value in the row as you have done: name[i][30] . So, as Ancient Dragon said, just reference the row: name[i] without using the rightmost index. The printf function will look for the first instance of a null value and stop there.

So, it might be a good idea to initialize the arrays before asking for information:

// Initialize arrays with null …
Ancient Dragon commented: right +17
D33wakar commented: using "gets" is a bad idea. -1
hkdani 39 Posting Pro in Training

You could do something like the following. This would prompt for good data. The
variable strAnswer will store the answer from the user. You might want to code
to validate the user's answer, though. This is just a general idea.

Private Sub CheckData()
Dim strAnswer As String
    If Combo1.Text = vbNullString Then
        strAnswer = InputBox("Please, enter proper data", "Data Error", "0")
        If strAnswer = "0" Then
            Exit Sub
        Else
            SaveData strAnswer
        End If
    End If
End Sub

Private Sub SaveData(ByVal GoodData as String)

End Sub
hkdani 39 Posting Pro in Training

The text property of the combo box returns the current value of the edit box according to MSDN documentation.

So, you must validate your data through code before saving it into your database. In other words, if the text in the edit box has been changed, your program must make sure that that data can actually be saved in that particular field of your oracle recordset.

You can do this in the change event of the combo control. This only works, if the style property is set to 0 or 1.

Private Sub Combo1_Change()
'  Code to validate the new value
End Sub

Otherwise, you'll have to write a function to check the data before saving it to the database.

Private Sub CheckData()
' 
End Sub
hkdani 39 Posting Pro in Training

You can use a Common Dialog Control. Add the Microsoft Common Dialog Control component to your project.

This control will return a Path to a file. Or you can use API's to do same. Little bit more flexibility.

But really. What you're requesting is not very clear at all. And I'm able to make little sense of what you really want.

If you have already opened the program, you should already know the path. Until you explain clearly what you really want to do no one can really explain to you how to do what you wish.

Here's an example of using the CommonDialog API's to return a Path.

Option Explicit
Private Const BIF_RETURNONLYFSDIRS = &H1      ' // For finding a folder to start document searching
Private Const BIF_DONTGOBELOWDOMAIN = &H2     ' // For starting the Find Computer
Private Const BIF_STATUSTEXT = &H4
Private Const BIF_RETURNFSANCESTORS = &H8
Private Const BIF_EDITBOX = &H10
Private Const BIF_VALIDATE = &H20              ' // insist on valid result (or CANCEL)

Private Const BIF_BROWSEFORCOMPUTER = &H1000  ' // Browsing for Computers.
Private Const BIF_BROWSEFORPRINTER = &H2000   ' // Browsing for Printers
Private Const BIF_BROWSEINCLUDEFILES = &H4000 ' // Browsing for Everything

Private Const OFN_READONLY = &H1
Private Const OFN_OVERWRITEPROMPT = &H2
Private Const OFN_HIDEREADONLY = &H4
Private Const OFN_NOCHANGEDIR = &H8
Private Const OFN_SHOWHELP = &H10
Private Const OFN_ENABLEHOOK = &H20
Private Const OFN_ENABLETEMPLATE = &H40
Private Const OFN_ENABLETEMPLATEHANDLE = &H80
Private Const OFN_NOVALIDATE = &H100
Private Const OFN_ALLOWMULTISELECT = …
hkdani 39 Posting Pro in Training

uhh kk... ill try and see what can i do...

Usually, there's a section in your Sequel Server Menu section that shows you how to set up your passwords. If you'll read the Help Menu for your SQL Server 2000, look for the section that deals with setting up a connection.

Apparently, you haven't done your homework. You need to do some digging.

hkdani 39 Posting Pro in Training

Try messing around with the Data Environment View.

From the View Menu choose Data View Window

Click on the second icon to add a Data Environment. You should then see a
Connection1 in Data Environment View frame.

Right Click on the Connection1 icon and choose the Properties Menu. At this point you should be able to figure out what settings to use if your SQL server is properly set up. If you still have problems, you need to read through the SQL documentation on how to setup your connection on your machine.

You don't need to use a Data Environment. But it's useful to teach you how to properly set up the parameters to use your SQL Server.

hkdani 39 Posting Pro in Training

http://www.connectionstrings.com/sql-server#p6

Probably the SQL OLEDB string is probably what you're looking for.

Get your SQL Server up and running first. Add a reference to the Microsoft ActiveX Recordset 2.x library in your project.

Instantiate your ActiveX Database Objects (ADODB) as follows:

Private rst as ADODB.Recordset
Private cn as ADODB.Connection


Private Sub Form_Load()
set rst = new ADODB.Recordset
set cn = new ADODB.Connection

cn.ConnectionString = ' Your Connection string

rst.open ' your recordset 
End Sub
hkdani 39 Posting Pro in Training

"Item cannot be found in the collection corresponding to the requested name or ordinal"

That usually shows up because the field name isn't spelled right or does not exist in the field names of the recordset.

hkdani 39 Posting Pro in Training

Try using something like the following for loading the control without a popup.

It works for password protected ftp sites: e.g. ftp://username:password@ftp.website.com

http://username:password@webaddress

hkdani 39 Posting Pro in Training

Hi:)
How can I scroll the report in runtime by mousewheel. I am using VB6 (SP6) and for reports I am using VB report control.

Which Report Control?

The Data Report Control?

Be specific and use the exact terms given in the VB6 environment.


To scroll a report control in the vb6 environment, you should check to see if the control supports mouse events: e.g. mouse down, mouse move, etc.

That's the easiest way to use the mouse in vb6. However, the data report control does not include mouse movement events. So you'll have to either modify the control by designing your own custom control or monitor the mouse events using the Platform SDK APIs that deal with mouse messages.

hkdani 39 Posting Pro in Training

What is the bug in the code?

#include <winsock.h> ?

Shouldn't you include <winsock.h> in your header?
That's where ntohs is found.

What compiler are you using?
Compiles fine with Borland 5.51 with winsock.h but generates an error when leaving out the winsock header.

Hank

hkdani 39 Posting Pro in Training

wow, good stuff
But, I just want to get the picture. so pretty much I need the page display of that pdf.
Do you what property should I use?
I have tried using .print property but it doesn't work (or maybe I am the one who didn't know how to use it). thanks

Like VB5 said, "Put a control on the form."

Click on the toolbar and add a component: Adobe Acrobat 7.0 Browser Control Type library 1.0

And then you have to set the properties and methods correctly to load a document. You can do this from a menu or in the Load of the form.

With AcroPDF1
         .Container = Frame1  ' or PictureBox1, etc.
         .LoadFile "D:\Documents and Settings\Joe User\My Documents\MyNew.pdf"
         .gotoFirstPage
         .Move 10, 10, Frame1.Width - 10, Frame1.Height - 10
         .setPageMode ("none")
        .Visible = True
         
End With

That should show it. You probably will have to mess with the resize event to resize the frame or the picture box when the form is resized.

hkdani 39 Posting Pro in Training

I'll try ODBC Direct and see where it takes me. Thanks.

Access97 uses Microsoft DAO 3.51 Object Library as opposed to the 3.6 Object library used by AccessOffice 2002

Your problem probably arises from the fact that you have loaded the a DAO Object Library that will not support the format of the data that you are trying to load. Either that or not loading the appropriate provider when using the ADO object library.

So, you probably should avoid using the DAO object libraries and use the ActiveX Data Objects 2.8 library exclusively since they should work with either version of Access97 or Access 2002.

dim rst as adodb.recordset
dim cn as adodb.connection

Private sub form_load()
     set rst = new adodb.recordset
     set cn = new Adodb.Connection

     With cn
          .Provider = "Microsoft.Jet.OLEDB.3.51"
          .open "c:\My Folder\myfile.mdb" 
     End with
      
     rst.Open "MyTableName", cn, adOpenDynamic, adLockOptimistic
End sub()

Notice the Provider property of the ADODB connection.

You'll probably have to have different functions to load the appropriate provider or use parameters in the function to load the appropriate Provider depending on whether it's Access97 or a later version of Access

Private Function Load_Access ( AccessVersion as Integer) as Boolean
     '   Instantiate your recordset and connection here   
      Select CASE AccessVersion
      Case 97 
           cn.Provider = "Microsoft.Jet.OLEDB.3.51"
      Case 2002
           cn.Provider = "Microsoft.Jet.OLEDB.4.0"
      Case Else
      End Select

      ' Load your recordset here
End Function()
hkdani 39 Posting Pro in Training

thanks for the info. Anything will do.
I don't need to do anything with the picture.
I just need to use it in "loadpicture" picture function and display it.
Which way do you thing is the easiest?
thanks a lot, it's relieve to know that it is possible

Graphics formats recognized by Visual Basic include bitmap (.bmp) files, icon (.ico) files, cursor (.cur) files, run-length encoded (.rle) files, metafile (.wmf) files, enhanced metafiles (.emf), GIF (.gif) files, and JPEG (.jpg) files(MSDN).

Looks like you have to convert the pdf file first into a format that's supported by the LoadPicture method , like vb5 said.

So, download a utility like he said and use the one of the Shell functions from VB6 or the Windows API to execute the utility to put the pdf into a jpeg. Then once that's done, you should have a converted jpeg file on your system that you can use in the LoadPicture method.

hkdani 39 Posting Pro in Training

No value in param1

Well, that's probably your problem. I would say you need some value there for your database command. You need to figure out why no value is in that variable at that point in your program.

Load DataEnvironment2
With DataEnvironment2
If .rsCommand1.State <> 0 Then .rsCommand1.Close
.Command1 Text2.Text
End With
DataReport2.Show

So, if you set a breakpoint at line 3 by clicking in the column to the left of the code, your program should stop at that point and you should be able to determine what value is in Text2.Text. You can use [F8] to step through your code 1 line at a time. If there is none, then you need to fix that bug so that your command1 will have a parameter that it can use. It can't use a NULL value.

hkdani 39 Posting Pro in Training

(param1 as long)

So, you answer my question with another variable. That's interesting. And so, if I ask you what the value of Param1 is you would give me another variable?

Perhaps Param2?

hkdani 39 Posting Pro in Training

What values are you getting for Text2.Text?
I don't understand

Text2.Text has a string value: e.g. "Joe", "Schmo","123", etc. If you put a break at this section of the code, what is it returning?

hkdani 39 Posting Pro in Training

.Command1 Text2.Text What values are you getting for Text2.Text?

hkdani 39 Posting Pro in Training
Option Explicit

Private Sub Form_Load()
   If App.PrevInstance = True Then
      MsgBox "Program already running.", vbInformation, "Program status"
   ' End the program
   End
  
   End If
End Sub
PinoyDev commented: has the expertise +1
hkdani 39 Posting Pro in Training

Nah, unfortunately that didnt work hkdani. But thanks for the post

That's funny: it works on my vb6 program. Actually, that's the method that I learned from a Microsoft CD on VB6 programming fundamentals. I've been using that method for years. It's odd that it doesn't work for you.

What I like about the method that Microsoft recommends is it's simplicity. That's why they made Visual Basic, because they knew that programs could be written faster and programmers could be more productive, if they were provided a simple way to perform a task such as the task you describe.

From what I've read and studied from the established authors and programmers, they always recommend the KISS method: Keep it Simple Stupid.

Yes, it's true that you can use API's. And it looks quite impressive. But in the end, in the real world it's all about achieving a desired end within a certain time frame.

If you can't achieve that end with the tools that VB6 provides, then VB6 has the flexibility of being able to call the Windows APIs from the Platform Software Developer Kit (PSDK). But as a general rule, use the tools that VB6 provides and only venture into APIs if VB6 doesn't provide the means to accomplish your end.

When it comes right down to where the rubber meets the road the end user will never see your code. He only sees your program. The programmer should not try to impress someone …

hkdani 39 Posting Pro in Training

Id like it so that when you click the 'x' button to close the program it doesnt just end.

Use the Form_Unload() event

Private Sub cmdX_Click()
     unload Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Dim intReturn As Integer
    
    intReturn = MsgBox("Ready to Exit", vbOKCancel, "Exit?")
    If intReturn = vbOK Then
    Else
        Cancel = True
    End If
End Sub