hkdani 39 Posting Pro in Training

I have this problem recently when I change my OS from winxp to suse linux 10.2. I want to run my visual basic 6

Visual Basic was made to code programs for Windows. If you're developing programs for Windows, use Windows. You're going to have to debug them in a Windows Environment, why would you want to develop them in a Linux Environment?

If you want to develop programs for Linux, learn C, learn C++, learn Java, learn Perl, learn TCL.

Good grief!

hkdani 39 Posting Pro in Training

access

Microsoft Access?

typing in the combo

I take it you mean searching through list that was loaded into the Combo Box.

You just have to extract the value from the current text in the combo, determine the size of the list in the combo, and then do a search using a loop until you find the value that matches.

Once you've found a match, you can stop at that point and determine the index at that value.

But you have to raise some type of event to determine when to perform the search. A command button would probably be the easiest:

Private sub Command1_Click()
   ' 1. Extract your typed text
   ' 2. Loop through the combo list to find the matching value and establish index values, etc.
  ' 3. Code to do whatever you want with that information.
End Sub
hkdani 39 Posting Pro in Training

I have been reading on the MS VB.NET environment and the first thing that hits me is that if I deploy my app. i have to include source code (although there is something called "CODE OBFUSCATION" or something like that.

That's if your using a web page form. That's the code behind the form. That's visible to the user. All he has to do is right click and choose View Page Source. But your executables that your web page application, if that's what your hoping to design, are stored in the binary directory on your web page server.

There are obfuscation tools that mangle your executables so that a de-obfuscator has a difficult and close to impossible task in stealing your code. But on a web page, you will have the above problem. Visual Studio provides an obfuscator.

MS-Access might be an outgoing product, so I have to choose from an more stable Data Base product like SQLExpress, Firebird or Mysql which are FREE and my path to the Internet should be transparent or at least easier. The key here is that potential customers WILL NOT INVEST on an full Database Package.

Access is still a viable option. But it seems a majority prefer MySQL. But I find that the largest problem is not the database, it's the person designing the database. If the database is designed properly using the first three standard normalization rules, that takes care of the majority of problems. Other databases are not a …

hkdani 39 Posting Pro in Training

i don't know to design the circuit

Hey, I'm not an electrician. You're wanting a VB6 forum to tell you how to do electronics?
Are you serious?

hkdani 39 Posting Pro in Training

VB6 and the internet are flaky.

That's why they upgraded to DOT NET.

But you can use the Windows API's to access the internet in VB6 ( which is probably what the DOT NET controls are built from anyway).

And you can use the drop in controls that come with VB6: the Microsoft Internet Transfer Control is probably what you're looking for.

If you want to use the APIs from the Platform SDK, look up WinInet. API's are a little bit confusing, if you're not somewhat familiar with C or C++, but with a little effort you can have a more robust application.

Hank

hkdani 39 Posting Pro in Training

how to save a visual basic form in any file format such a jpeg?

A Visual Basic Form is not a picture form. It's a container for other objects.

In that sense, you can save the form with the picture on it.

There are other contols that you can use on the form to hold the picture: the PictureBox, and the Image control. You have more options with the PictureBox control

But you can set the picture property in the Property View and select a picture to be used on your form. Any controls dropped on the form will cover the picture.

hkdani 39 Posting Pro in Training

I need to color few items

What's an item? This is pretty vague stuff here.

You want to color the text, the background, an object item?

hkdani 39 Posting Pro in Training

Well the program that i have is actually a C program that can print data in a text file. It doesnt even print the numbers but makes a "wave-like" design using " * "

Do you have the code for the C program?

If it's taking advantage of one of Microsoft's DirectX SDK APIs, a C programmer could probably take advantage of the same API's to produce a wave file from the text data. But more than likely a lot of the information about the original sound (texture, quality, resonance, etc.) would be lost.

The C program probably just extracts the frequency and the duration of the pitch and outputs a text character at a particular position. It's not that complicated. But I wouldn't bet the outhouse on being able to reproduce the same original sound from just the text data.

Hank

hkdani 39 Posting Pro in Training

scrrun.dll

That's the exact name of the dynamic link library (dll).

In that library of functions, the file system object can be referenced and used.

To add a reference to your project, simply click on the the Projects menu, click on the References Menu, and a form should show up listing the different libraries that are registered to be used with Visual Basic.

They are in alphabetical order. Look for Microsoft Scripting Runtime and check it's box, if it's not checked already. The Microsoft Script Control is a component used for writing scripts. It does not include the File System Object.

In the declarations section of your form you should declare your own File System Object. Declare an object variable

Option Explicit
dim MyFS0 as FileSystemObject
Dim strFileName as String

And then you should instantiate the object or make an instance of the object using the Set statement

Private Sub Form_Load()
  Set MyFSO = New FileSystemObject
  ' You can now use it.
  if MyFSO.FileExists(strFileName) then
    '  Code if it exists 
  else
    ' Code if it doesn't exist
  endif


'  Be careful to reclaim your variable space in memory after done using the object
Set MyFSO = nothing
End Sub

More in depth information should be gleaned from the MSDN Library: What Can You Do With Visual Basic: Processing Drives, Folders, and Files

hkdani 39 Posting Pro in Training

You have a choice of normal or small.

It's in the properties.

I really doubt that firefox wrote a VB dropin ActiveX control so that VB6 users could use their control.

VB6 is limited to what's available or what you can develop yourself.

hkdani 39 Posting Pro in Training

1. You need to determine the size of the word.

Dim strArray()

Private sub DetermineSize
  dim intSize as Integer
  intSize = len("Good")
  lblText = String(intSize, "-")

End sub

I really don't know, if that helps you.

hkdani 39 Posting Pro in Training

what is the possible answer

I would say that you have two choices: (1) Check with the program that made the wave file. See if it comes with a dll that you can reference in your program to accomplish what you ask , or (2) Identify the wave file with the text file so that you know which text file represents which wave file.

If the first choice is a possibility, you will have to figure out how to use that program's dll in your program.

The second choice is easier and only requires a little imagination. I would just use the first 20 or so characters of the text file created from the wave file and use it to identify the wave file.

Make a one-to-one association between that text value and your wave file. Based on the identity of the text file, just play the wave file that corresponds to the text file. You don't have to convert the file from text to wave, you just play the appropriate file based on the value of the first 20 or so characters that the program produces.

hkdani 39 Posting Pro in Training

folder one= "F:\STAFFSTREAMA\A1\SALES\SALESDATA_A1"

Dim intCounter as Integer
Dim strFileName as String

For intCounter = 1 to 200
  strFileName = "F:\STAFFSTREAMA\A" & cstr(intCounter) & "\SALES\SALESDATA_A" _
      &  cstr(intCounter) & "\salesdata_a" & cstr(intCounter) & ".xls"
      ' Code to open your spreadsheet
      ' ............................................... 
next intCounter

I don't know if that's what you're looking for? But if you have the same file name, you won't have to use the last part of the above string: you can just the same name with no variable to create a new file name.

hkdani 39 Posting Pro in Training

Hey guys first time learning VB6 and i have to do a Hangman project for my Gr 10 class

You have several errors in your English.

Hey, guys. This is the first time learning Visual Basic 6.0 (VB6). And I have to do a hangman project for my GR-10 class.

This is a more acceptable sentence structure.

You know, the mind is like a muscle: the more you exercise it, the stronger it becomes.

I'm not counting the spelling errors. They are too numerous to mention. If you hope to be of help to someone in the future, please first learn to help yourself by taking on the responsibilities incumbent upon a responsible descendant of Adam. If you will be faithful in the little things of life, people will call upon you for help in the bigger things.


But in answer to your problem ................

Your posted code is quite impressive. The style is excellent.

And I really think with a little effort you will come up with the answer.

hkdani 39 Posting Pro in Training

You need to use The File System Object. Add the Microsoft scripting runtime dll in your Project reference menu, first.

Option Explicit
Dim fso As FileSystemObject
Private Sub Form_Load()
Dim strFileName As String
Set fso = New FileSystemObject
strFileName = Text1.Text
If fso.FileExists(strFileName) Then
   MsgBox "Blah, Blah, Blah, the File exists", vbInformation, "File Status"
Else
   MsgBox "Blah, Blah, Blah, the File does not exist.", vbInformation, "File Status"
End If
Set fso = Nothing
End Sub
hkdani 39 Posting Pro in Training

This is what I did to backup my DB whenever I had to - problem is I'm not sure how to find the file to restore it.

Typically, Microsoft recommends storing that type of information in the registry. In Windows 3.1 days, they stored it in the program's INI file.

For the registry use the GetSetting and SaveSetting functions

SaveSetting App.Name, App.Name & "Settings", "BackUpPath", backupDBPath

' Retrieve it
GetSetting App.Name, App.Name & "Settings", "BackUpPath",  App.Name ' Last Value is a default value, if it's not present

If you're adventurous and curious and have a desire for the deeper knowledge in the world of VB programming, then investigate the GetPrivateProfileString and WritePrivateProfileString functions.

hkdani 39 Posting Pro in Training

windriver software

What's windriver software?

If you don't have a drop in DLL or ActiveX control provided by the manufacturer that can be used by VB6, then you need to develop your own. Consult the USB Communication Device Class (CDC) Specification version 1.1 for further details. Your questions are outside of the scope of this particular forum. This is Visual Basic 4/5/6 with emphasis on the BASIC.

hkdani 39 Posting Pro in Training

"MyApp", "MySection",MyKey","MyValue"

Try reading the MSDN documentation. Those are just names I made up. You have the freedom to make up your own.

Use regedt32 from the run command: Check the HKEY_CURRENT_USER section: Software/VB and VBA Program Settings

MyApp is a name you give to an application found in the VB and VBA Program settings section

MySection is the name of a sub folder of the Application Name

MyKey is a name you make up for a field

and MyValue is the actual value.

You can search the MSDN.com legacy section if you don't have your own MSDN CD's installed.

hkdani 39 Posting Pro in Training

Now as you well know, every bodies computer has different User Account Names, so how am I suppose to get around this problem ?

' Declaration Section
Public Declare Function GetEnvironmentVariable Lib "Kernel32" _
   Alias "GetEnvironmentVariableA" (ByVal lpName As String, _
   ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Sub cmdFetchEnv_Click()
   On Error GoTo Fetch_ERROR
   Dim lngReturn As Long
   Dim strVar As String
   Dim strBuffer As String * 255 ' Be careful to declare this as written, otherwise you'll get
   ' a runtime error that you will not be able to recover from.
   Dim strMiddle As String
   Dim intPos As Integer
   
   ' The lngReturn value should give the length of the Environment Variable
   ' the txtEnvir variable should filled in with "USERPROFILE" for your purpose
   ' but can be replaced with any Environment Variable: TEMP, OS, PATH, etc.
   lngReturn = GetEnvironmentVariable(txtEnvir, strBuffer, 255)
   If lngReturn = 0 Then ' An error occured, process it.
      GoTo Fetch_ERROR ' Oh, my soul. A dreaded GOTO statement
   End If
   ' Use the left function to cut off the unwanted null characters
   strVar = Left(strBuffer, lngReturn)
   ' You need to cut out the "\" characters to find the actual user name
   intPos = 1
   While intPos <> 0
      intPos = InStr(1, strVar, "\", vbTextCompare)
      strVar = Right(strVar, Len(strVar) - intPos)
      intPos = InStr(1, strVar, "\", vbTextCompare)
   Wend
   ' This should be your answer as to the username
   txtEnvResult = strVar
   Exit Sub
Fetch_ERROR:
   Dim LastError As Long
   LastError = Err.LastDllError …
hkdani 39 Posting Pro in Training

VB6 has support for serial ports. You could purchase a USB to serial adapter and use a Microsoft COMM control in that case. But that seems to be your only option with working with Visual Basic, if the hardware manufacturer did not supply any drop in ActiveX controls, DLLs, etc.

If he did, most of your work is already done and you won't need a USB to serial adapter.

If not, then your manufacturer better have supplied with you with some SDK detailing how the hardware responds to communication events.

But you would have to some knowledge about how to set the baud rates. receive modes (binary or text), and how the device responds inside the ONCOMM event. Most of your coding will take place there inside the ONCOMM event:

Private Sub MSComm1_OnComm()

End Sub

-------------------------------------------

"I smell a rat"

hkdani 39 Posting Pro in Training

hey can anybody help me.. i want to interface my hardware with the PC through usb port.... and my application program is written in vb6.0...so do i need WIN DRIVER type software for low level programming and then call win driver libraries in vb 6.0 or else? can somebody send some sample code in vb6.0 for this that can help me?...thanx in advance

What USB device are you wanting to use? What hardware are you wanting to interface? What specifically are you trying to accomplish?

You simply haven't given enough information to provide an answer.

hkdani 39 Posting Pro in Training


SO REFERENCE TO THE WORKBOOK IS F:\STAFFSTREAMA\A1\SALES\SALESDATA_A1.XLS
I HAVE 200 OF THESE WHICH GO FROM A1 TO A200, folders with THE SAME named FOLDER CALLED SALES and same workbook called salesdata_A1 ETC.

I need to be able to go through each folder eg A1,A2 ETC OPEN THE protected workbook select a cell range from a specified worksheet eg JANSALES and copy the data to one worksheet on my local drive.
please help, thanks a billion.

Your answer is in the name of your folder. Fortunately, the name is somewhat consistent:

Dim strFolderName as String, , strUseThisName as String, intCounter as Integer
strFolderName = "F:\STAFFSTREAMA\A1\SALES\SALESDATA_A"
for intCounter = 1 to 200
  strUseThisName = strFolderName & cstr(intCounter) & ".XLS"
  ' Enter code here to process your request
  ' ...................
  ' ...................
next intCounter

But this is only part of your request. Sounds like you'll need to program a VBA script in a separate Excel workbook (most likely your worksheet on your local drive) to accomplish what you're asking. So you probably could use the above as a starter in a VBA script in the Excel Program.

hkdani 39 Posting Pro in Training

In the first place, there's no need to drop a document onto your project, form, or whatever. All you need to know is where the location of the file is.

And then you need to establish some process with a command button, a click event (on a form), etc. to call up the desired document.

You're shooting yourself in the foot.

I don't wish to load this document into my project using the open dialog control every time the user opens my project or use any load or shell commands

It is not possible to not load something into memory that you want to load into memory that you want to use. A shell command is the easiest and quickest solution. You could use an API from the SDK. But that would be more difficult.

What are you trying to accomplish, hide yourself from a user who is running a program that blows up the world if it detects a load a shell request from Visual Basic?

hkdani 39 Posting Pro in Training

Is there any property for grid controls
Or how to resolve through coding.
Thnx.

use the format function:

format(sngValue, "##.##")

Private Sub Form_Load()
   Dim sngValue as Single 
   sngValue = 52.345
   MSFlexGrid1.Col = 1
   MSFlexGrid1.Row = 1
   MSFlexGrid1.Text = Format(sngValue, "##.##")
End Sub

Notice, you have to set the Column and row you're working with before setting the value of the text.
Check your MSDN documentation of the format property.

hkdani 39 Posting Pro in Training

Is it possible to make a wav file with the available data from the text file and play it in VB.

In programming just about anything is possible. But if you're asking this question thinking that VB has a built in capability to do what you're asking, think again.

You're greatest chance of success of doing what you're asking comes from the program that is able to convert the wav file into a text file. Does that program have the capability to convert the text back into a wav file? And does that program offer any dll's or APIs that you can reference in VB to accomplish that goal.

The real person that you should be asking this question is the person who wrote the program that can convert a wav file into a text file.

hkdani 39 Posting Pro in Training

I've been searching a lot, but couldn't find anything about what I would imagine to be pretty easy.

Private Sub List1_Click()
   Dim strListValue As String, sngPercentage As Single
   strListValue = List1.List(List1.ListIndex)
   ' Check for numeric value to avoid run time error
   If IsNumeric(strListValue) Then
      Text1 = Format(CDec(strListValue) * sngPercentage, "currency")
   End If
End Sub
hkdani 39 Posting Pro in Training

When I click on a number of persons the price is displayed...

But I need a way to change the prices so they must not be in the coding!!!

What is 'they': the prices or the persons?

and i need to save these values on closing of program so that they stay the same next time I open the program!!!

The simplest way to save data without much overhead is to use the registry.
Use the following:

SaveSetting  "MyApp", "MySection", "MyKey", "MyValue"

Use GetSetting to retrieve the data.

You probably want to save the index value. On the form load event you can retrieve that Index Value using GetSetting and then set the Index value with that value. I'm assuming that you already have the prices saved in the list of your properties as well as the values for your combo boxes.

hkdani 39 Posting Pro in Training

.CommandText = Array("SELECT `Total Fleet Current NA`.`Railcar ID`, `Total Fleet Current NA`.NBV, `Total Fleet Current NA`.`Adj NBV`" & Chr(13) & "" & Chr(10) & "FROM `Total Fleet Current NA` `Total Fleet Current NA`" & Chr(13) & "" & Chr(10) & "WHERE (`Total Fleet Current NA`.", "`Railcar ID`='MMMX028762')")

You're wanting to replace part of a string: or the part after Railcar ID.

Just declare a couple string variables.

Dim strSequel as string, strID as string
strSequel = "SELECT `Total Fleet Current NA`.`Railcar ID`, `Total Fleet Current NA`.NBV, `Total Fleet Current NA`.`Adj NBV`" & Chr(13) & "" & Chr(10) & "FROM `Total Fleet Current NA` `Total Fleet Current NA`" & Chr(13) & "" & Chr(10) & "WHERE (`Total Fleet Current NA`.", "`Railcar ID`='"

strID = "Whatever"

strSequel = strSequel & strID & "')"

.CommandText = Array(strSequel)
hkdani 39 Posting Pro in Training

hkdani - the only potential problem I can see with that is my database is in a different folder than what app.path return, the folders that each are in are in the same location, also I can't really go up a directory and specify the folder name because every time I install them then the folder names change - don't know why.

You are installing them. You are installing what? You are installing the database files after installing the program? You are installing pictures? Need more information. Are you talking about installing the program?

The installer should install the Program in a default location: usually the <Program Files > folder. You need to follow some good practices on your locations: (1) Data that will be used by All Users, should go in the All Users directory, and (2) Data that will be used for the personal user should go in that User's Directory.

Currently I am saving it to a directory that I know where it is (C:/Program Files/PortGen2.0)

That's not a good practice, hard coding locations. You should use the GetEnvironmentVariables with the Environment Class in Visual Basic to find where the Program Files folder is, AllUsers, CurrentUser, etc.

Which allows me to save it, but not restore it because I don't know where to load the file if something were to happen to the old one.

You simply need to save two locations: (1) Your Backup Location, and (2) Your Active Location--or the location you …

hkdani 39 Posting Pro in Training

hkdani - the only potential problem I can see with that is my database is in a different folder than what app.path return, the folders that each are in are in the same location, also I can't really go up a directory and specify the folder name because every time I install them then the folder names change - don't know why.

You are installing them. You are installing what? You are installing the database files after installing the program? You are installing pictures? Need more information. Are you talking about installing the program?

The installer should install the Program in a default location: usually the <Program Files > folder. You need to follow some good practices on your locations: (1) Data that will be used by All Users, should go in the All Users directory, and (2) Data that will be used for the personal user should go in that User's Directory.

Currently I am saving it to a directory that I know where it is (C:/Program Files/PortGen2.0)

That's not a good practice, hard coding locations. You should use the GetEnvironmentVariables with the Environment Class in Visual Basic to find where the Program Files folder is, AllUsers, CurrentUser, etc.

Which allows me to save it, but not restore it because I don't know where to load the file if something were to happen to the old one.

You simply need to save two locations: (1) Your Backup Location, and (2) Your Active Location--or the location you …

hkdani 39 Posting Pro in Training

All of the folders repeat some sort of information, but none of them have all of the information, so this one will have the database and maybe the icon or something, and another will have the icon and the forms in it, there is one folder for each of the interops that I used (word, excel and

But what I recommend for dynamically finding the appropriate directory is to either store the information about the data's path in an older INI file (See the Platform SDK for Read/WritePrivateProfile) or to use the registry.

But I would declare a public variable in one of your modules to use as a reference in the program.

Public mpProgPath as String

Retrieve the value on loading:

mpProgPath = GetSetting("My Program", "StartUpValues", "AppPath", cstr(App.path))

And then, you can use that as a basis for your other directories where you have information stored:

strDB_PATH =  mpProgPath & "\db"
strImage_Path = mpProgPath & "\Images"
hkdani 39 Posting Pro in Training

I give you this by way of welcome and advice. Take it as you will.

Thanks, for the welcome.

I feel much better now.

hkdani 39 Posting Pro in Training

First off, your response has nothing to do with the OP's problem.

Had the same problem. Same messages. That was my solution offered up on the friendly, Microsoft Managed newsgroup. It's an answer from my humble experience.

Secondly, don't resurrect two year old threads unless you have something amazingly earthshaking to contribute.

If it works, who needs it be earthshaking?
I'm a newb here. And don't exactly appreciate the 'cold' welcome on my first post.

But I do appreciate the fine article on the site about the fellow who enjoyed the forum because of the friendliness of the people on the forum.

Hank

hkdani 39 Posting Pro in Training
#include <windows.h>

int main() 
{

....
}

You need to link against the shell32.lib when compiling.

Not familiar with the IDE, but on the command line

c:\> cl /EHs prog.cpp /link shell32.lib

hkdani 39 Posting Pro in Training

I'm using the following code compiling with cl.exe from VS .NET 2003:

// shell.c
#include <windows.h>
#include <iostream.h>

int main() 
{
  SHELLEXECUTE (NULL, "open", "Notepad.exe", NULL, NULL, SW_SHOWNORMAL);
  return 0;
}

But receive this error:
shell.obj : error LNK2001: unresolved external symbol, __imp__ShellExecuteA@24
shell.exe : fatal error LNK1120: 1 unresolved externals

I'm finding that it's easier to run ShellExecute from VB than it is in C. I must be missing something in the include statements?

Thanks for any help.

Regards,

Hank