added a data declaration under the .data section.
.data
hStdout dd 0
Seems to have fixed it.
Using /ax for the tlink32 param allows td32 to load symbol tables.
added a data declaration under the .data section.
.data
hStdout dd 0
Seems to have fixed it.
Using /ax for the tlink32 param allows td32 to load symbol tables.
Using tasm32. GetStdHandle returns INVALID_HANDLE_VALUE in eax register.
.386
.model flat
extrn GetStdHandle:PROC
extrn ExitProcess:PROC
.data
.code
start:
push -11
call GetStdHandle
push 0
call ExitProcess
end start
Other APIs work fine. just having problems with GetStdHandle. Any ideas?
I want to pass multipule arguments of different datatypes.
Everything is identified as a string in VB6 with the Command() command.
It's the responsibiilty of the programmer to test and categorize the string data to determine if it can be classified as numeric: e.g. textvb6.exe seven 6 horses could be run on the command line. You would have three string values: seven, 6, and horses. Only "6" would test out as numeric using the IsNum() function.
i tried to change the location of the access within the codes, but i failed.
As mentioned previously, don't hardcode locations of filenames.
Your application should normally store its data in the Application Data folder. Microsoft has given a name to this location for each user: %APPDATA%
So, an accepted practice is to save your data files in this folder using the following format: %APPDATA%\Company Name\MyData.xml
Saving your data in this manner insures that the data will be stored in the same location on different computers--even if the application data folder does not follow the same naming convention with a different operating system: e.g. Windows XP as compared to Windows 8.
You should use an installer program to install your program on another computer. Your development environment has met all the dependencies; otherwise, your program would not run.
Use the Package and Deployment wizard. This should pick up all the dependencies and install the appropriate files needed for your program and ressiter them to run on a different computer.
The Package and Deployment Wizard, however, is really out of date. But it can be used as a basis for Visual Studio Installer 1.1 to make a Microsoft Installer (MSI) file.
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.
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
Again, if you want help, post the code that you have already tried. The guidelines explicitly say that you are to submit a request with your attempts at writing code.
That being said you could use the hide and show methods for currently active forms:
frmFirst.Hide
frmSecond.Show
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.
Read the MSDN Documentation. It has the answers.
The properties of the Printer object initially match those of the default printer set in the Windows Control Panel. At run time, you can set any of the Printer object properties, which include: PaperSize, Height, Width, Orientation, ColorMode, Duplex, TrackDefault, Zoom, DriverName, DeviceName, Port, Copies, PaperBin, and PrintQuality. For more details and syntax for these methods, see the Language Reference(MSDN).
After messing with this, apparently, you can't use the Me keyword inside of a user control. In other words, the user control cannot reference itself in code as in a normal form--as far as I can tell.
You can, however, just use the key words Width and Height. So in a user control Me.Width should be replaced with Width and Me.Height should be replaced with Height to obtain the current Height and Width of the user control.
Looks like the only problem with this workaround is that you can't take advantage of the Me keyword and you would have to know in advance which controls are inside the user control.
If someone knows how to reference a user control inside of itself, that would make it simpler. But that apparently is the root problem that you're mentioning in your first post or the reason you cannot use the resizer inside the user control.
Private Sub UserControl_Resize()
Dim ctl As Control
For Each ctl In Me
' Write code to deal with the different controls inside the UserControl.
Next
' Previous code will not work
' Write code to deal with known controls on the user control.
' Not very flexible. But that's the only solution that I could come up with at this time.
End Sub
I can re-size the UserControl but the controls on the UserControl are not resizing.
The User Control has its own resize event. You could write could in that event to resize the controls inside that control. That would be the most logical place to try.
Private Sub UserControl_Resize()
Dim ctl As Control
For Each ctl In Me
' Write code to deal with the different controls inside the UserControl.
Next
End Sub
I cannot be found in the collection corresponding to the requested
name or ordinal...
I would agree with BitBlt. I've seen that error popup when I misspelled the field name. In other words, the requested name does not exist because of my spelling error.
Sometimes I err on the side of caution and go ahead and convert a text value to a number. I know VB6 usually goes ahead and converts a string value to a numeric data type; but I err on the side of caution and convert the string value to a numeric type before sticking it into the Sequel statement just out of habit from using other programming languages that don't allow this flexibility.
Public Sub CalculateEquation (ByVal X as Integer, ByVal Y as Integer)
Form2.label1.Caption = X * Y
End Sub
Function retassoc(fn As String, fpath As String) As String
You might want to include ByVal in front of your variable parameters. By default, if you leave ByVal or ByRef out of the parameter declaration, the function will be looking for a variable. Sometimes functions intend to change the variables that are passed as parameters. If that's not your intention, then you might want to consider adding ByVal. That would force the user to enter a value, a string, integer, etc. for the parameter. Otherwise, the user has to declare a variable to pass to the function. Function retassoc(ByVal fn As String, ByVal fpath As String) As String
The error is generated by access app.
MSAccess Windows open and tells that file c:\Documents and Settings\MyUserName\MyAccess.mdb is not present.
To generate the error code in VB first, you must test the file in VB first. You can use the Microsoft Scripting Runtime Library and use the File System Object. You might try using the ShellExecute API. It returns error codes for File not found, file association errors, etc. I haven't tried it. But if you start using these extras such as file system object, Checking Error Codes on running the ShellExecute API, I would say your request for making a simple executable to run an access file is not really that simple. If you're a novice, as you say you are, then the best you can hope for is copying and pasting somebody else's code to accomplish your purpose. Or you're going to have to do some digging and show some personal effort to figure out what's going on and why.
Some database fields require input for each field: even if you don't have a value to input. So if you're using numbers, you might supply the number zero where a null field would show up. But sometimes the field requires input, but it requires a string value. So, you provide a space string value for that field, if you don't have any input for that particular field.
Dim strName as string
if strName = vbNullString then
strName = " " '
rst.Fields("Name") = strName
else
rst.Fields("Name") = strName
End if
Something along those lines. You need to know which fields require a value. And you need to add a value that will work with that field that you can recognize later as a missing value, in case you to need to add a record to a table without having all the information at the time of the recordset update.
http://www.daniweb.com/software-development/visual-basic-4-5-6/tutorials/355095
Use your eyes. Use a little bit more effort.
The error is generated by access app.
MSAccess Windows open and tells that file c:\Documents and Settings\MyUserName\MyAccess.mdb is not present.
That's just an example of an imaginary file name. You have to supply the correct file name that is on your system. I have no idea what your database file's name is, where it is on your hard drive, etc. You need to code in the correct file name.
The Shell function returns the TaskID of a process. Otherwise, it returns an error. You can trap it as follows:
Public Sub Whatever(ByVal strProgram_With_Parameters as String)
On Error GoTo Err_SHELL
Dim dblReturn As Double
dblReturn = Shell(strProgram_With_Parameters, vbNormalFocus)
Exit Sub
Err_SHELL:
MsgBox Err.Description & " Error " & Err.Number, vbCritical, "Error"
End Sub
Thanks for reply
i am still getting error with your codeerror is
Compiler error:
Sub or function not defined.
i am new to vb and just want a vb comiled EXE to run MSACCESS mdb or accdb database.
It would help if you would list what sub or function was not defined. Usually the compiler stops on the function that is not defined and has it highlighted.
Don't make it too complicated.
If you want to use the Shell command, do something similar to the following: Shell "c:\Program Files\Microsoft Office\MSAccess.exe " & "c:\Documents and Settings\MyUserName\MyAccess.mdb", vbNormalFocus
The Shell Function expects the program name and it expects any parameters, such as the filename, to be separated from the program name by a space.
The ShellExecute API is simpler; but you can just use the the word "open" with the second parameter, and the filename with the second parameter. But just try the Shell first: it should work.
You can add an Acrobat Control Component to your form. One of the functions of the control will be to print a PDF document. You probably need to do some investigation on how to use the control. But you can go to Adobe's website. They do have an SDK you can download and use with VB6 along with documentation and examples on how to use the components they give you.
You use the same method as described before. But you have to use code to determine the first and last day of the required month.
Thirty days hath September,
April, June, and November;
All the rest have thirty-one,
Save February, with twenty-eight days clear,
And twenty-nine each leap year.
You can use a Select Case Statement to set up a string for the number of Days, and then you have to use the appropriate value with the year for your SQL Query.
Private Function ReturnDateQuery (ByVal MyDate as Date) as String
Dim strSQL as string
Select Case Month(MyMonth)
Case 2 ' February
Case 5, 6, 9, 11 ' April, etc.
Case else
End Select
' Write code to include first and last day of month and the particular year to return the proper SQL string.
ReturnDateQuery = strSQL
End Function
You receive the error because you are sending a value; i.e. your file name.
If the function requires a variable, then you need to send a variable that you declared in your function. When your function uses ByRef, then you need to send a variable. To get around the error and to use the function as is, just declare a variable and give it a value before sending it to the function. The function can then change the value of that variable, but it does not sound like it will. So, that function probably could have been more efficiently written by using ByVal. Unless the programmer's intent was to optionally change the value of the variable.
When you use the ShellExecute API you can just use "open", "print", or "explore" for the second parameter. In your case, you just want to use "open" for the operation. The operating system will use the program that is designated in the windows registry to open a file with that file's extension.
If you use the VB Shell function, you then must use the actual name of the program plus any parameters that may accompany the file. You need to use a space between the program name and the parameter; hence, chr$(32).
You have more options, if you use the ShellExecute API. But it's more complicated. The following example uses both the ShellExecute API and the VB Shell function. The VB Shell function just performs a limited set of the …
Glad you found the error. Sometimes the Package and Deployment Wizard (PDW) does not pick up all the dependencies and you have to add the files yourself.
Well formatted and well written code. For a beginner you have picked up some good habits. Keep up the good work.
You need to have the user select the week and then you need to use that week in a SQL Query statement. If you're using an ADODB recordset, it shouldn't matter what database engine you're using.
Format your code.
You're using adOpenStatic for a SQL statement. I usually use a an adOpenDynamic when working with SQL statements. And adOpenStatic with Table Searches.
But if you're getting that error, you probably should put a stop point after opening up the recordset and then checking in the command window while in debug mode to see if you have any records selected with that query. If your record count shows 0 or null, then you probably have an invalid SQL statement, you just don't have any records that meet that criteria, or you are not using the proper recordset type.
I'm guessing that you should use adOpenDynamic. But it's hard to tell without any data to check.
You create a query statement based on the dates you want to report on.
You must input that data using some type of date control--which would probably be best. Or you can have the user type in the date he wishes to query. But that leaves you open to date format errors.
Step through the code and then tell us at what line the exception is raised.
I tried to format what you had. But it was an exercise in aggravation.
Here's one thing to avoid doing:
Don't Use a With, End With statement in the middle of a series of For Next Statements. It may work: but it's murder trying to decipher.
Don't forget to use indentation in your code. And don't hesitate to use comments and white space to separate code processes. It may not be necessary, but it certainly helps readability and will not slow down the execution of your program.
For i = 1 to 10
' Code
' More Code
Next i
With MyForm.Control
.Open
.Close
End With
For i = 1 to 10
' Code
' More Code
With MyForm.Control
.Open
.Close
End With
' Keep your With/ End With inside your For Loop. It looks better and is easier to follos.
Next i
Yes, but you need to use the following Windows API to do that.
BOOL SetWindowPos(
HWND hWnd, // handle to window
HWND hWndInsertAfter, // placement-order handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
UINT uFlags // window-positioning flags
);
(MSDN)
Public Const HWND_TOPMOST = -1
Public Const SWP_SHOWWINDOW = &H40
Public Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Function SetMyWindowPos(ByVal WndHdl as long, ByVal ByPosition as Long, ByVal Left as long, ByVal Top as Long, ByVal WinWidth as long, ByVal WinHght as Long) as Long
Dim lngReturn as Long
lngReturn = SetWindowPos(WndHdl, ByPosition, WinLeft, WinTop, WinWidth, WinHght)
' lngReturn should return a nonzero value if successful, 0 if it fails
End Function()
Use the HWND_TOPMOST Constant for the second parameter, and the SWP_SHOWWINDOW Constant for the last parameter.
Something like the above should work. Ask, if you have further questions. If you don't it be on top when you leave the application, then you'll have to write extra code to deal with that situation: e.g. when your application loses focus, and again when your application returns focus to put the back on top again.
Try using monospaced fonts or fonts that are not proportional such as True Type Fonts (TTF). If your printer switches the font from a font that is used on your form, and it switches to a monospace font, then the spacing will be off. Sometimes your printer will supply fonts to use with the printer specifically
Good grief. You're using a C# .NET DLL and trying to place it in VB6?
Maybe you're really trying to place a C or C++ .NET DLL and place it a Visual Basic 6 project? In which case, you're in the wrong forum. Go to the Visual Basic .NET forum.
I don't believe a C++ .NET DLL is compatible with VB6. I've tried this before and have had the same result as you posted: "Can't add a reference to the specified file."
You can create a DLL using the C or C++ programming language to use in VB6. But you have to follow the guidelines for working with VB6. I don't even know that you can create a C# DLL.
You need to read the text file using the Microsoft Scripting Runtime Libary or
just use the older file function Line Input to loop through the lines of the text file.
If you use the Scripting Runtime Library, then you'll need to use the TextStream Object using its ReadLine function to loop through the lines of the text.
Use a loop to read and keep track of the lines storing the individual lines in a string array. If you declare an integer variable to keep track of the number of lines read in the loop, then you can use its last value to determine the last line read. And the previous value will be one less.
The previous post shows how to use Line Input. But you'll need to add code to save the individual lines of code so that you can use the saved values to enter into your MySQL database.
Office 2007 uses a different library. Someone had posted a similar problem a few months ago. I believe the Office 2007 Access uses a different database engine than the Jet engine (versions 2.x, 3.51, 4.0, etc.).
But use the following reference library from the Project/References menu: Microsoft Office 12.0 Access Database engine object Library. Access 2000 uses the Jet 4.0 engine, not the same engine as Access 2007.
VB6 was designed with the Jet Database engine as the database of engine of choice. However, it's nice to know that you can still use the newer up to date engines in this classic programming tool.
If I had
txtWord, txtLetter, txtReplace, lblAnswer, cmdNewwhere would i put it in the code
Enter your code in the cmdNew sub
Private Sub cmdNew_Click()
Dim intLen As Integer, intPos As Integer, intCounter As Integer
Dim strNew As String, strBuild As String
intLen = Len(txtWord)
lblAnswer.Caption = ""
intPos = InStr(1, txtWord, txtLetter, vbTextCompare)
For intCounter = 1 To intLen
If intCounter <> intPos Then
strBuild = strBuild & Mid(txtWord, intCounter, 1)
Else
strBuild = strBuild & txtReplace.Text
End If
Next intCounter
lblAnswer.Caption = strBuild
End Sub
Personally, I would use the following method to save and locate your database:
Dim strDataLocation as String
strDataLocation = Environ("APPDATA") & "\My Program Name\MyData.mdb"
SaveSetting "My Program Name", "StartUp", strDataLocation
' Use this type of code or similar to save a public value for strDataLocation. And use that value for this variable repeatedly throughout your program to locate or save your data.
Check out the documentation on the Date Time Picker Control.
You have four different property values for format on the Date Time Picker control: use either dtpTime or dtpCustom as mentioned previously.
If you use dtpCustom, then you have to add runtime code to set the custom format for the control: e.g., dtpPicker1.CustomFormat = "hh:mm:ss"
You need to use standard locations for your database location when you publish your program: use the Application Data Folder; e.g. Application Data\Program Name\MYdata.accdb.
Look up Virtual Folder Names in MSDN. The Application Data folder is a virtual folder. So as long as you are using virtual folders, they will install in the same place on any machine. And when you make calls to access the database, make sure that you use the appropriate function to find that virtual folder.
The Application Data Folder is the folder recommended by Microsoft to store your application's data. Use the following format: Application Data\Program Name\MyDatabase.accdb
The problem is not your database engine. The problem is writing code that will be universal on a PC using the Windows Operating System. Also you're in a VB6 forum and you are using VB.NET (Visual Studio 2010).
I realize the word publish can be used to describe the installation process; but it has several different meanings in programming. Just use the word install: e.g. I'm having problems installing my program.
I still have no idea what you're saying. And I can read between the lines.
I have an array of size 6 called apparray(6).
That by default is an array of size 7. Visual Basic 6 uses a Zero Based Index for arrays unless specifically told that the index starts with 1.
I have stored several strings into this array from textboxes. Two of the text boxes, lastName and firstName, has the value of 'Smith' and 'John', therefore apparray(0) and apparray(1) have the same values. How do I now display these values on a multicolumn listbox using the array?
' Previous code assumed to have filled values for apparray(6)
Dim i as Integer
For i = 0 to 1
list1.AddItem apparray(i), i
Next i
The system selects passages from the text passages and build the output MSWord RTF document.
That's probably the source of your problem. You're converting from varying formats. If you just want to preserve the text, convert the RTF source texts to plain text before building your final RTF document.
If you want to try and keep the formatting of the source text, then make convert all text sources to a common RTF version before combining or adding them to the final RTF document.
You can use the File System Object with its Drives collection object to find the serial number of a hard drive. Finding serial numbers on RAM and Motherboards is more complicated and involves being able to access the BIOS and accessing different areas of memory not normally accessible through visual basic commands or even Windows APIs. A knowledge of how to use the C programming language along with assembly language may be necessary to extract the information you wish for memory modules and CPU information.
Some of the information about the CPU can be determined using the GetSystemInfo API
with the SYSTEM_INFO structure.
Option Explicit
Private Declare Sub GetSystemInfo Lib "kernel32" Alias "GetSystemInfo" (lpSystemInfo As SYSTEM_INFO)
Private Type SYSTEM_INFO
dwOemID As Long
dwPageSize As Long
lpMinimumApplicationAddress As Long
lpMaximumApplicationAddress As Long
dwActiveProcessorMask As Long
dwNumberOrfProcessors As Long
dwProcessorType As Long
dwAllocationGranularity As Long
dwReserved As Long
End Type
Dim fso As FileSystemObject
Private Sub Form_Load()
On Error GoTo DriveError
Dim drv As Drive
Set fso = New FileSystemObject
For Each drv In fso.Drives
Debug.Print Hex$(drv.SerialNumber)
Next
Exit Sub
DriveError:
Resume Next
End Sub
Dim tmData as Date
tmData = format (DatePicker1.Value, "Short Time")
I'm making a program like Notepad but better! But i don't know the code for the Open and Save buttons! Can someone please tell me the code? (I'm using VB6)
Try using the Common Dialog Control. Add the Common Dialog Control Component to your form. Right Click on the Toolbar and choose components and choose the Microsoft Common Dialog Control.
The Common Dialogue control has several different methods for different purposes and is a simplified version of the Win32 SDK API for the Microsoft Common Controls.
"Method Dialog Displayed
ShowOpen Show Open Dialog Box
ShowSave Show Save As Dialog Box
ShowColor Show Color Dialog Box
ShowFont Show Font Dialog Box
ShowPrinter Show Print or Print Options Dialog Box
ShowHelp Invokes the Windows Help Engine (MSDN)"
Private Sub FileOpen_Click()
CommonDialog1.ShowOpen
End Sub
That should get you started. And here's a link for some further instruction. Using the Common Dialog Control should be one of the skills you should quickly become familiar with to give your application a unified and professional appearance.
'form 3rd form
Dim p As String
Private Sub Form_Load()
Label1.Caption = Form1.p
End Sub
You're using private variables from another form. If you want to use the variables from another form, you must declare those variables as Public and not Private.
Once you use Form1 followed by the period, then anything after the period belongs to the object Form1 and not to the form that you are currently on.
As i what i said i want automatically unlocked after do some changes.
As the programmer, you must make the decision as to when you want the text box to be enabled or disabled. If you want the text box enabled after making the changes, then you have to write the code to make that happen.
I have only a vague idea of when that should be, since I'm not the author.
after some make changes of the text box info it will lock again?
Again, you have pointed out the need to write code to respond to an event in your program.
You need to determine the appropriate time for locking the text boxes. This could be when the appropriate data has been entered: you might want to test for appropriate data.
If the user is using the add button to input the final result of his answer, then you could add code in the add button click event to disable the text boxes. And then use the edit button click event to enable the text boxes.
This would make sense. You can't edit if the text boxes are disabled. So enable them in the code for the edit button click event.
The user should be done editing when he clicks on the add button; so, disable the text boxes after posting the results.
Private Sub cmdEdit_Click()
TextBox1.Enabled = True
End Sub
Private Sub cmdAdd_Click()
' Add code to post user's answer.
' Possible code to test user's answer before posting
' if user's answer is satisfactory --> Enabled = False Else Enabled = False
TextBox1.Enabled = False
' etc.
End Sub
Hola. Que Tal?
Use an Adobe Acrobat Browser Control Type Library.
If you have Adobe's Acrobat Reader installed, it should show up as a component in your Visual Basic Components. Add this control to your form.
And then use something similar to the following to load a file: AcroPDF1.LoadFile "C:\AcrobatSDK\Adobe\Acrobat 9 SDK\Version 1\Documentation\pdf_reference.pdf"
without clicking the edit, delete, and add button
That's the key to your solution. Write code in the click event of these buttons to enable the text box controls so that the control will respond to user activity.
TextBox1.Enabled = False ' Need to set this at design time or at an appropriate time during the execution of your program. This property set to false disables interactive use.
TextBox1.Enabled = True ' Set this property during a click event to allow the user to interact with the Text Box Control.