vb5prgrmr 143 Posting Virtuoso

By putting the retrieval and insertion of those excel cells in a procedure and pass to the procedure where you want the loop to start and end as its arguements...

Good Luck

vb5prgrmr 143 Posting Virtuoso

It is real easy to define a sub or function but the choice on which may be the hard part. For example...

Public Function MyFunction() As Long

End Function

Public Sub MySub()

End Sub

So your choices are...
Public/Private Function/Sub (optional argument list) as somethingoranother

End Function/Sub

Just remember, a sub does not "traditionally" return anything and a function normally only returns one thing.

Now, for further clarification on the "traditionally" statement. A sub can return many values as a function can also do but both do these indirectly (for lack of a better way to word it...)

For example...

Private Sub Command1_Click()
Dim MyInputString As String, MyOutputString As String
MyInputString = "This is a test."
MySub MyInputString, MyOutputString
MsgBox MyOutputString
End Sub

Private Sub MySub(InStr As String, OutStr As String)
OutStr = InStr
End Sub

So how/why does this work? Well in VB6.0 and vba (if I remember correctly about vba), arguements are passed by ref by default and as such, the called procedure can change those values. However, if the procedure declares the arguements ByVal then VB makes a copy of that value before the called procedure recieves it.

Now you can do the same thing with the arguements of a function if you so wish or you can leverage the power of the function to return a UDT (User Defined Type)...

Private Type MyType
  A As Integer
  B As Long
  C As Byte
End Type

Private Sub Command1_Click() …
vb5prgrmr 143 Posting Virtuoso

Okay, before you check for a quantity, check for records first...

So when users enters something and searches, your process would be something like this psuedo code...

strSQL = "SELECT * FROM tablename WHERE fieldname = '" & user_input & "'"
open rs
If rs.recordcount <> 0 and rs.bof = false and rs.eof = false then
  'okay we have records
  if rs.fields("quantityfieldname").Value <= 0 Then
    'okay, no stock available so notify user
  else
    'stock available
  end if
else
  'no records so notify user
end if

So once again, first check to see if you have returned any records, then check to see if you have a value to work with.

Also, what I originally said was this...
>So, change the bof/eof check into an if end if in by itself and then put your <=0 check after that...

perhaps I should have explained it better as I hope I have this time...

Good Luck

vb5prgrmr 143 Posting Virtuoso

With VB you can accomplish a lot of what you want with the format function. Other functions like Space, Len, and Me.TextWidth("string") would also be of help. Now, when printing with the printer object you can do one of two things. You can use the currentx/y properties to alter where you place your next piece of text or you can format the entire line with other functions like spc and tab (see Print Method in vb's help).


Good Luck

vb5prgrmr 143 Posting Virtuoso

Did you place a picture box on the mdi parent form and hope to show a mdi child form in it??? If so, the SetParent API is what you are looking for. If not, are you sure you set the mdichild propert to true in the intended child form???

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, I finally reproduced your error (yeah! :)) and when this happens to you, click on debug. VB will then take you to the offending line...

If mch_rs!mch_qtyh <= 0 Then

but just four (4) lines below that line you have the error check needed....

If mch_rs.BOF = True And mch_rs.EOF = True Then

So, change the bof/eof check into an if end if in by itself and then put your <=0 check after that...

Good Luck

vb5prgrmr 143 Posting Virtuoso

I get your message box that says "sorry mchnno 123 not found in merchandise_table" but let me follow what you do...

Okay, when I input h1010 again, I get the message box that says "Sorry..duplicate entry H1010 you already have purchase"

Okay, now I click add and display clears, I start over with c0001 and type in h1010 and it displays record in grid with quantity of zero with no error or no notice. So I enter 1 and get the message box that says insufficient stock... So go back and enter 123 and get a message box of item not found in stock...


Add Error handling!!!! and change the option to break on unhandled errors...

Good Luck

vb5prgrmr 143 Posting Virtuoso

No error here...

Add error handling as I posted above...

Good Luck

vb5prgrmr 143 Posting Virtuoso

I don't know where you found your information that printing to tiff is a sepeate piece of software that you need to operate, because my searches "windows print to tiff" and "tiff print driver" both found tiff printer drivers for windows that "ANY" software can print to just as if it were a HP or lexmark printer...

and yes it is possible...

1st) Download and setup tiff printer driver and make it the default printer driver..
2nd) shellexecute API with "print" verb the *.pdf file in question
3rd) Download and setup if needed WIA 2.0
4th) Use WIA 2.0 to open and display tiff image in picture box

Good Luck

vb5prgrmr 143 Posting Virtuoso

ShellEddie, it is not nice to highjack someone elses thread as you have done...

Your problem, if you are using ADO, is more than likely your connection string, so go over to http://www.connectionstrings.com to correct yours. Now, if using DAO, that is your problem, DAO does not recognize the database format above 2k...

PS. I'm flagging your post as a bad post because of your highjacking. In the future, if you need to reference someone elses thread, or an older thread (called necroposting), copy its URL into your brand new thread...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, I looked over your Form12, as it was the startup object, and it seems to work for me...

In that, if I put a part number in that does not exist, it gives the the correct error, and if I use a good part number, it displays a quantity of 1 in the grid and 7 in stock. I also changed F1010 to a quantity of zero and recieved what I believe to be the correct error message but I would say you need to add a little more information to that msgbox.

So at this point, everything seems to work okay but you say you are getting a runtime error... What is the error number and err.description?

Note: To make it easy to retrieve this information, you should put error handlers in all of your subs and functions... Something like this...

Private Sub Form_Load()

On Error GoTo Form_LoadError

'your code goes here

Exit Sub
Form_LoadError:

MsgBox "Form12 Form_Load " & Err.Number & ":" & Err.Description

End Sub

Good Luck

vb5prgrmr 143 Posting Virtuoso

If...Then, Select Case, ElseIF are condition statements found in any language and thus are not intrinsic to vb as they are code branches based upon conditions found withing the code that, no matter what language is used to derive these branches, when compiled they should all be the same, or nearly the same. While on the other hand, Dir, Instr, Mid, Trim, Left, Right, UCase, LCase, GetSetting, SaveSetting, and so on are intrinsic to VB and are interpreted by the VB runtimes. And finally, the API, as I understand it, circumvents the vb runtimes and communicate with the dll in question directly.


Good Luck

vb5prgrmr 143 Posting Virtuoso

Those pictures don't tell me a thing... We need to see the code to be able to help you...

vb5prgrmr 143 Posting Virtuoso

Adodc1.RecordSource = "select * from marks where roll = " & troll.text 'will work now....

Also, in the future, do not necropost or highjack a thread as you have done both here. Instead, if you need to, copy the older threads url into your brand spanking new thread as a reference...


Good Luck

vb5prgrmr 143 Posting Virtuoso

Actually, any intrinsic function to VB will require the runtime, however, the use of the API will not as I presently understand it. But your problems can be solved by simply using the PDW or some other installer...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Don't really need the pic, just the code but if you use the Go Advanced button you should be able to attach a pic...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Well you know what!!! Instead of me trying to write this for you in the blind, how about you first post the code you have for loading the grid in the first place and we will work from there...

vb5prgrmr 143 Posting Virtuoso

Your going to go D'oh here in a moment :) ...

An autonumber is a number and not text so when quering against a number you do not wrap it with single ticks (')...

Good Luck

vb5prgrmr 143 Posting Virtuoso
strSQL = "SELECT * FROM tblWhatever WHERE quantity > 0"

Good Luck

vb5prgrmr 143 Posting Virtuoso

Not a problem, now if you don't mind could you please mark this thread as solved... thanks

vb5prgrmr 143 Posting Virtuoso

Close, very close, but add a boolean variable... (Also, since you are not returning anything from this procedure, it can be a sub instead of a function...)

Public Sub readExtFile1(filename As String)
Dim TimeToWrite As Boolean

Then, there are a couple of mistakes in your code we need to correct...

Line Input #nFileNum, sNextLine
[B]sText = sText & sNextLine & vbCrLf[/B]
If [B]text[/B] = "NEW" Then
WriteToTextFile (sNextLine)
End If
Loop
Close nFileNum 'missing something here see below

It should be...

Line Input #nFileNum, sNextLine
  If UCase(sNextLine) = "NEW" Then TimeToWrite = True
  If UCase(sNextLine) = "@NNNN" Then TimeToWrite = False
  If TimeToWrite = True And UCase(sNextLine) <> "NEW" Then WriteToTextFile (sNextLine)

Loop
Close [B]#[/B]nFileNum

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, you use the word "add" but actually the word would be "subtract" from what you are telling us... Now, please consider this fictitious table...

tblInventory
iInvID
vInvName
vInvDesc
iQty

and lets say it contains your H1010 in the vInvName field with a description of A Blue Widget, and a quantity of 10.

Now, when you sell or transfer these ten items from your inventory, you would update this quantity by say using an update statement...

strSQL = "UPDATE tblInventory SET iQty = [tblInventory].[iQty]-" & variablethatholdshowmanyweresold & " WHERE iInv = " & variablethatholdstheiInvID

Now, you question is, is how to know when the values of iQty changes or what it is? Well when you first pull the data from the database, you know it then. It resides within the recordset that you used to retrieve the information so that is where you would check to see if there is sufficient quantity to subtract from the inventory. Then after your update, you would want to Refresh your recordset so that it will be updated with the latest amounts...

Good Luck

vb5prgrmr 143 Posting Virtuoso

If you want just the picture then search the web for print to tiff or tiff printer driver. Set it up on your computer and print the pdf to either a multipage or many single page tiffs. (Those configurations will be found in the documentation of the tiff driver.) Either use the control or the shellexecute API with the "print" verb or do it manually. Go to M$ and download (if you need to) the WIA 2.0 SDK. You will need this to be able to load a tiff image into a picture box on win xp systems and later. If on 2k or earlier you can use the wang/kodak imaging controls.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Place picture box on form, size it, select control from toolbox, and draw it into the picture box.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Well a picture box is meant to hold graphics while the adobe acrobat 7.0 browser control type library 1.0 will allow you display pdf files... So are you wanting to put this control into a picture box, or are you wanting to use one of those print to Tiff drivers to print the adobe pdf via the shellexecute API with the "print" verb and then use WIA 2.0 to load and display the output in a picture box???

Good Luck

vb5prgrmr 143 Posting Virtuoso

kw2k9, just so you know, DAO is faster than ADO when it comes to the older access databases and when using DAO to access certain blob/memo type fields you do not need to use the getchunck method that you would have to do with ADO to get the contents of one of those fields...AND DAO can access any kind of database that ADO can via ODBC Direct! Just so you know...

ALSO, RDO is faster and more reliable than ADO also... Since ADO is a wrapper for both DAO and RDO and thus is slower as it adds another layer of calls...

Just so you know... :)

vb5prgrmr 143 Posting Virtuoso

Switch over to ado or save the 2k2 database in a previous format 2k or 97...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Not a problem, now if this is solved could you please mark it as so...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, right click on the toolbox and select components. When the dialog comes up, scroll down to Microsoft Windows Common Controls-2 6.0(SP6)>select>OK (BTW: SP6b found at MS). Then when you hover over the controls, the control you are looking for will have a tooltip of DTPicker...


Good Luck

vb5prgrmr 143 Posting Virtuoso

Just so you know there is a calendar control in VB already but that did not stop me either... Now, as it seems you are just learning, the question comes on how much you do actually know? Do you know how to create controls at runtime by either loading controls in arrays or by creating objects? Do you know about the various date functions? Do you know how to tell which years is a leap year?

Now, I could go on and on with the questions but I don't want to overload you with them. Best bet, since creating this thing will cover many areas, is to start with some code that accomplishes part of your task and if you have any problems with that code come back, post your code and we will try and help you...

Good Luck

vb5prgrmr 143 Posting Virtuoso

As I showed you before in your original thread http://www.daniweb.com/forums/thread268844.html you need to have some code to set the variable and some code to retrieve the value and since vb is an event driven language, that code you write is more than likely to stem from an event, LIKE THE CLICK EVENT OF A COMMAND BUTTON! It will NOT just appear automatically! You have to do somecoding of some sorts!!! And as I pointed out, it was an example!!! You could use the form load event if you wish it does not matter but under some event the code must go!!!

vb5prgrmr 143 Posting Virtuoso

It's an example....

vb5prgrmr 143 Posting Virtuoso

Precautions in designtime to consume less memory... (you would watch the vb6.exe memory consumption in debug mode...)

Use control arrays as much as possible.
Don't over crowd forms with controls.
If you can, put as much code into modules and classes as you can as the forms graphical elements take up a lot of memory.
When using data access methods and you have a table with an extreme amount of records, don't use a select * unless you absolutly have to for your program.
When you can unload formname/set formname = nothing to totaly remove it from memory.
And this goes with the one above... Don't use public variables in the forms because if you need access to the information contained within that variable, you have to keep at least part of the form loaded. So put the public variable in a module and that way you will have access to it from everywhere when you need it.
Don't load an excessive amount of graphics into memory (icons, who cares, but pictures like bmp's, jpeg's, and the like, yeah you gotta watch those).
The same thing can be said about files you open up, meaning text files and such that you open with the Open Method.
When you can, use an image control instead of a picturebox control or a label instead of a textbox... i.e. use the lightest weight control you can for the purposes needed at hand...

Good …

vb5prgrmr 143 Posting Virtuoso

Code in Form1...(Add Command Button (Command1))

Option Explicit

Public MyPublicInteger As Integer

Private Sub Form_Load()
Load Form2
Form2.Left = Me.Left + Me.Width
Form2.Top = Me.Top
Form2.Show
End Sub

Private Sub Command1_Click()
MyPublicInteger = 4
End Sub

Code in Form2...(Add Command Button (Command1))

Option Explicit

Private Sub Command1_Click()
MsgBox Form1.MyPublicInteger
Form1.Command1.Value = True
MsgBox Form1.MyPublicInteger
End Sub

Run and click on form2's command button and if you need to, step through it with F8...

Good Luck

vb5prgrmr 143 Posting Virtuoso

kinwang2009, it is you that is mistaken as neosonic stated in post #1...

>I want to save the whole picture into a bmp file (including the multiline textbox).

(I think you are confusing the print screen function, which takes a picture of the desktop or a particular window and allows you to save that image to file, with printing to a printer...)


Unfortunatlly neosonic, your options are limited but what you can do is use the printscreen method shown to you to capture the image of just the textbox. Then use that image to alter the original image by using bitblt api or the slower paintpicture method. Then, once that is done, you would use the savepicture method which will save the graphic as a bitmap...

Note: There are methods of saving the contents of a picture box as a jpeg but this will involve a lot more code and definitly delving into the API and if you use your friends (yahoo, google, ask, answers, bing) and search for vb6 save jpeg, you should get some sample code...

Good Luck

vb5prgrmr 143 Posting Virtuoso

You want hardcore, these guys have hardcore... http://www.thescarms.com/VBasic/timer.aspx

Good Luck

vb5prgrmr 143 Posting Virtuoso

Time to use your friends (yahoo, google, ask, answers, bing) and search for vb6 ReadProcessMemory or you could use the task manager to see how much your program takes up in memory...

Good Luck

vb5prgrmr 143 Posting Virtuoso

q2, requests like this can get you banned from almost every forum site I know of as your request is illiciting illegal behavior. Meaning that it is still illegal to download "free" copies of VB6. Now I know as the rest of us do that you don't want to do anything illegal so you have a few choices. One is to go over to nextag.com and search for any of the following...

Visual Studio 6.0 Enterprise
Visual Basic 6.0 Enterprise

Visual Studio 6.0 Professional
Visual Basic 6.0 Professional

You can also try ebay and or your friends (yahoo, google, ask, answers, bing) but I would suggest you add the word buy or purchase to your queries...

And Finally, purchase the MSDN subscription from M$ and then from M$ you can download any of the versions I noted above.

Good Luck

vb5prgrmr 143 Posting Virtuoso

See this faq for more information... http://www.vbforums.com/showthread.php?t=555378

Good Luck

vb5prgrmr 143 Posting Virtuoso

Well using integers will not allow for the showing of cents or decimal value portions of a dollar...

MsgBox Format(-1000.45, "$#,#.00;-$#,#.00")

Good Luck

vb5prgrmr 143 Posting Virtuoso

Well Student02, I kind of got a kick out of reading your posts as my mind or experience has sometimes gone along the same path as you have shown your mind's travels... :)

Good Luck

vb5prgrmr 143 Posting Virtuoso

It is not that much different if I remember correctly, just replace rs with adodc1 and you should be able to use the same queries in its recordset arguement...

Good Luck

vb5prgrmr 143 Posting Virtuoso

To begin with, you cannot format an autonumber within the field itself, which does not mean you cannot format it for display, but it does mean you will need another field to store this formatted number and it will need to be a text field. It also means that you will also need another table to store that last student number used for current year...

tblLast
iYear 'current year
iNo 'this is the auto number

Now, this above table will only ever have one record...

So, your process will be...

With the student name information, check to see if student exists.
If student does not exist then
Select * from tblLast
'check to see if we are in same year or have we moved into the next
if Format(Rs.Fields("iYear").Value, "yy") <> Format(Year, "yy") then
UPDATE tblLast SET iYear = " & Year & ", iNo = 1"
StudentIDStringValue = Format(Year, "yy") & "-0001"
else
StudentIDStringValue = Format(Rs.Fields("iYear").Value, "yy") & "-" & Format(Rs.Fields("iNo").Value + 1, "0000")
UPDATE tblLast SET iNo = [tblLast].[iNo]+1"
End IF

And then from there you could/can insert your record into your student table...

Good Luck

vb5prgrmr 143 Posting Virtuoso

As kinwang2009 pointed out, the use of the msgbox function is called for here, but as you may be wanting to have a custom message box, you will need to show the form vbmodal and/or return a value from that form.

Load FrmMsgBox
FrmMsgBox.label1.caption=”Do you want to save the record?”
FrmMsgBox.Show vbModal, Me
If GblMsg = 1 Then Call SaveRecord

Then in FrmMsgBox you need to add Unload Me to each buttons click event AFTER you set your global variable...

Good Luck

vb5prgrmr 143 Posting Virtuoso

That len in the left should contain something different that the desitination in itself...

As for helping you through it, you are creating it at runtime, or it looks like it from your query form there and what you want... You just need to follow the help files in creating your report...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Should be if you pass the proper query to the report...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Use the tag property of the text box...

Good Luck

vb5prgrmr 143 Posting Virtuoso

With better english.... To do what you want would require you to subclass the message box, which is no easy thing, and then you may not be able to accomplish what you want. So, your only choice is to create a form that you can use as a message box by showing it modal...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Time to use your friends (yahoo, google, ask, answers, bing) and search for vb6 word automation tutorial...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Hmmm... Well you might be able to get away with setting the listindex instead of the text...

Option Explicit

Private Sub Form_Load()
Combo1.AddItem "A"
Combo1.AddItem "B"
Combo1.AddItem "C"
Combo1.AddItem "D"
Combo1.AddItem "E"
End Sub

Private Sub Command1_Click()
Dim I As Integer
For I = 0 To Combo1.ListCount - 1
  If Combo1.List(I) = "C" Then
    Combo1.ListIndex = I
    Exit For
  End If
Next I
End Sub

Good Luck