Comatose 290 Taboo Programmer Team Colleague

Try using msgbox's at the critical portions of the code to determine that the values are right. The reason I say this, is because it's been my experience that VB's IDE doesn't do a very good job of changing variable values in the IDE. So, for example, you could do this:

ublic Function Getareaname(flname As String) As String
Dim fposn As Long, i As Integer
    Dim fName As String
    Dim tmpname As String
fName = "d:\getarea"
    fposn = 11
    msgbox "starting loop"
    For i = 1 To Len(flname)
        msgbox "at first if"
        If Mid(flname, i, 2) = "//" Then GoTo skipnext
        msgbox "value is: " & mid(flname, i, 2)
        If Mid(flname, i, 2) = "u:" Then GoTo skiplev
        If Mid(flname, i, 1) = "/" Then Mid(fName, fposn, 1) = "\" Else: Mid(fName, fposn, 1) = Mid(flname, i)
        fposn = fposn + 1
skipnext:
    msgbox "at skip next"
    Next i
    Getareaname = fName

You can add and remove msgbox's as necessary to help trace variables through your code, and figure out where it's going wrong. If you could attach a copy of the file you are passing to this function (or an example of it) then I can try to trace it myself, but since I don't know the layout inside of the file, it makes testing your function a little more difficult.

Comatose 290 Taboo Programmer Team Colleague

Hmn, I don't understand the problem with the picturebox.... you can make it load pictures from files and what not, right? Maybe we can make excel export the graph (and only the graph) to a file?

Comatose 290 Taboo Programmer Team Colleague

You don't need a database for that. You could use a flat file, so long as you encrypt the password. Most of these "password files" are set up in the old unix fashion, where each username / password combination is stored on 1 line in the file (so if you had 10 users, you'd have 10 lines in the file). The username and the password would be separated by a delimiter (usually colon), and then split at the time of the read, so something like this:

comatose:myencryptedpassword
hollystyles:hisencryptedpassword
keratinimp:yourencryptedpassword

Then, when the user types in the username and the password, you encrypt the password that they just typed in, the EXACT same way as you encrypted the password they typed in for the file. If the two encrypted passwords are the same, then they are good to go (and if the usernames are the same).

Comatose 290 Taboo Programmer Team Colleague

Hmn, I think you just need to set a reference to it in project/references... check this page out: http://www.lvr.com/parport.htm#Programming

Comatose 290 Taboo Programmer Team Colleague

Hmn, I can't seem to find anything specific to changing the volumes of each channel, but I've found API's to work with stereo (2 channel) and it looks directsound (sub of directx) can handle multichannel devices, but it doesn't give me anything specific for changing the volume, here is some of the resources:
api:
http://www.mangovision.com/vbapi/ref/funcc.html#audio

directsound:
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/htm/directsound.asp

Comatose 290 Taboo Programmer Team Colleague

Right, Paul had the right answer. You'll also find (which may be a better solution, since the .refresh method doesn't give windows a chance to update anything other than the textbox) that the doevents function will also work. Doevents, unlike .refresh, gives your app a chance to process events passed by the user. An example of this, is to stick another button on that form, for "quit", and have it have some unload and end code (like so):

for each XFrm in Forms
     unload XFrm
next XFrm

' /* Code Should Never Reach Here, But Just In Case */
End

Then, click your button to make the words change, and right after, click the Quit button. With the .refresh method, you'll see that it takes a lag time before ending the application. If you use the Doevents function, your application will respond more promptly to device control. The example I have here isn't as extreme as it could be (say, by having another textbox in which you type in at the same time), but it's enough to show you the difference between .refresh and doevents.

TxtWords.Text = "Hello"
DoEvents
Sleep 300
TxtWords.Text = "Cookie"
DoEvents
Sleep 300
TxtWords.Text = "Train"
DoEvents
Sleep 300
TxtWords.Text = "Cat"
Comatose 290 Taboo Programmer Team Colleague
Comatose 290 Taboo Programmer Team Colleague

Right, I get that, but what for? If you tell me what you are building, I might be able to come up with an alternative method of doing what you want....

EDIT: Here is a quick program that I threw together that has 3 picture boxes.... the main picturebox, and then the two pictures that get put into the 1 picturebox. So, picture2 and 3 contain the template pictures, and then you'll see in the code on form_load, that I use bitblt to load both pictures in the 1 picturebox, 1 directly beneath the other. You may want to play with the second bitblt a little, try changing it's Y position, or X position, and see how it looks and what it does. Anyway, here you go...

Comatose 290 Taboo Programmer Team Colleague

Ok, well, what exactly are you trying to accomplish? I mean, are you trying to display a picture, and then display another picture over it (like a watermark or logo)? You could always use bitblt and write both pictures to the same box, but you'll have to do quite a bit of trial and error to figure out where you want the other one to be placed.... let me know what you are doing, and I'll see what I can do.

Comatose 290 Taboo Programmer Team Colleague

:( it seems you are right about the savepicture method. Here is some code I found (however, it requires an external .dll) http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=21298&lngWId=1, that will allow you to convert a .bmp to a .jpg format, but doing this manually is going to be rough. You'll have to open the file for binary access, and then write the appropriate bytes of information to the file. If I can find a better jpeg file format resource, I could cruft up some code on this...

Comatose 290 Taboo Programmer Team Colleague

If you want to use the same picturebox to display 2 pictures, you'll have to find a way to make VB merge the two pictures in the format you want. Why can't they be different pictureboxes, made to look like one?

Comatose 290 Taboo Programmer Team Colleague

You don't need it in array of bytes. Once it's in a picturebox, you can simply call the SavePicture function built into VB. SavePicture picture1.picture, "c:\newfile.jpg" , check here: http://experts.about.com/q/Visual-Basic-1048/Resizing-JPEG-VB6.htm, however, if you are truly hell-bent on doing it the hard way, here is something to look at:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=50065&lngWId=1, and if you know a bit about working with files opened for binary, you can learn about the JPEG headers and file format in these:
http://www.obrador.com/essentialjpeg/headerinfo.htm
http://www.codeproject.com/bitmap/iptc.asp
Let me know how it turns out, and what you decide to do.

Comatose 290 Taboo Programmer Team Colleague

first of all your making it way to hard on your self just open the picture in a different program and save it as a jpeg picture.

As a programming forum, using a different program and saving it with that doesn't make much sense.....

Comatose 290 Taboo Programmer Team Colleague

I've never used starnet, so I can't help you there. If you have an API of some kind, or have code to add things to starnet, then I can point you to a place to get data from excel.....

Comatose 290 Taboo Programmer Team Colleague

Ah sure.... assuming it was VB.net that logic would make sense.... but we are in Legacy VB ;)

Nice code, by the way. It's elegant, and tasteful.

Comatose 290 Taboo Programmer Team Colleague

Wow, that's uh, the wrong language.

Comatose 290 Taboo Programmer Team Colleague

Most likely only .txt and rtf files. If you want to do processing for other kinds of files, you'll need to manually try to format the data and display it. One trick that I thought was a pretty good plan, was have the program check to see if MS word is installed, and if so, have VB use Word behind the scenes to convert the file to a .txt or a .rtf, and then display it that way (I mean for documents, if you want to do pictures and stuff, you'll have to use picturebox's or apis with device contexts....)

Comatose 290 Taboo Programmer Team Colleague

You are talking about a link in a textbox that opens a file? In the textbox, or in whatever program would normally open it? I mean, what exactly are you trying to do?

Comatose 290 Taboo Programmer Team Colleague

Something to note when using a richtextbox, is the method "loadfile", which will load a .txt file (or an RTF File... Actually, it will load any file, but you might want to stick to .txt and rtf with it). You can do it that way, which is real easy, but not so much fun. Like this richtextbox1.loadfile "c:\boot.ini" , which load the file "boot.ini" from root of the c drive (c:\). If you are dead set on doing it the hard way (which I am) you can use open, which follows this syntax open path for action as handle

Comatose 290 Taboo Programmer Team Colleague

Thank you Sir.

Comatose 290 Taboo Programmer Team Colleague
Comatose 290 Taboo Programmer Team Colleague

As a mod I should see those "deleted" posts..... hmn, maybe you need to post a hijack this in the spyware, viruses, and nasties section!?

Comatose 290 Taboo Programmer Team Colleague

If you don't know VB, you'll want to start off with a guide to learning VB from the ground up. Also, don't let there be any confusion about which language you are using. A lot of people don't know this, but THERE IS A DIFFERENCE between Legacy VB (Vb4, 5, or 6) and VB.Net and Vb Express.... Vb.net and Vb Express are basically the same thing, but they are different than Vb6. They have a different set of properties, a different set of objects, and a different set of methods. So, make sure you know which one you are using, and make sure you know which one you are learning.

If you need help with any of the VB6 issues, you can feel free to ask, and I, or someone knowledgeable here will answer your questions. Your project isn't a simple hello world program. It's not something as intense as building a video game, but it's not a walk in the park either. It's a great project to help you learn. Let me know where you are at, and where you are going, and I'll try to help.

Comatose 290 Taboo Programmer Team Colleague

Yes. You are not talking about doing this over the internet though right? I mean, you don't plan to have this database stored on the internet, and his collection and all? Basically, he downloads the program, installs it. It COMES WITH the entire database (which is not editable) and he has another database of his own collection (that is editable). He can add cards from the main database to his collection, right?

Yes. This is possible in Vb.

Comatose 290 Taboo Programmer Team Colleague

You should read these two tutorials first, and then we can work on excel specifically. The tutorials are about word, but automation of word, and excel are identical, with the exception of a few objects and methods (there are links to excel info also).

http://www.daniweb.com/tutorials/tutorial51307.html
http://www.daniweb.com/tutorials/tutorial51315.html

Also, are you doing this in VB, or in the VB built into Excel?

Comatose 290 Taboo Programmer Team Colleague

I don't understand what you want to do.... I do know that VB can work with databases (both structured database [access, oracle, SQL], and non-structured, such as flat files). I'm not sure what you want to do with the card stuff, but I know VB can show pictures.... of anything, such as cards, or hands or whatever. Let me know in a bit more detail what you want to do, and I can see what I can do for you.

Comatose 290 Taboo Programmer Team Colleague

Who's Spamming?

Comatose 290 Taboo Programmer Team Colleague

He made a minor error in his code, it should look more like this (notice the word "open" in place of "opened"): mciSendString "set cdaudio door open", 0&, 0, 0

Comatose 290 Taboo Programmer Team Colleague

True, but for the question asked the else was unnessesary to expand because this is an example of how to use isNumeric, not an example of how to design an IF. And all I did was answer the question
asked, I didn't correct his value/text mistake because he would find it quickly enough, and the focus was on the question asked.

Ok Waltp,

I understand where you are coming from, and that's ok, but understand this also: the forum is not simply meant to answer questions, it's meant to help people become better programmers in the VB Language. Some people who come to this site, have a difficult enough time, trying to differentiate something as simple as the differences between certain data types. As people who help others, it's a responsibility of ours to not only answer the question, but to answer the question correctly and precisely. Programming is a practice of precision, and so should our answers be.... if we encourage poor programming practices (such as using else's in an if block when it's not necessary) we our only making things more difficult for ourselves, when the user posts his nearly completely project with a bunch of empty else's in it. I'm sorry If I came off harsh in my reply by constructively criticizing your code, but I just want to make sure that INI is informed to the very best that we can make him informed....

That said, if we take a closer look at …

Comatose 290 Taboo Programmer Team Colleague

I think we're getting away from the original question, which was
Doesn't this mean:I have a number in a text box. How can I tell if I need an Integer or a Long when it's converted from ASCII to binary?
Or am I interpreting this wrong?

I would guess that he wants to ensure that numbers are all that is in the textbox, especially if he wants to see if the data entered is a long or integer.... so It looks to me as though the information is entirely relevant.

Lover99509: Right, because long is a integer type. You could cast it to a single, instead of clng, you could use csng, or cdbl. Which would cast it to a single or a double, which are both floating points. That would maintain your decimal point, and solve you from having to do string parsing.

Comatose 290 Taboo Programmer Team Colleague
If NOT [B]isNumberic[/B](Textbox1.value) then
    Msgbox("Sorry you must only put numbers")
else
end if

It's a cleaner code method to not include an else unless it's being used. Also note that VB6's textbox's do NOT support the .value property, instead, use the .text property. So, the above code example:

if not isnumeric(text1.text) then
     msgbox("Sorry you must only put numbers")
     exit sub
end if
Comatose 290 Taboo Programmer Team Colleague

zip it, and then attach it (you might have to click the "advanced" button below. Then I can see what you are doing, and try to follow along with your explanation of what it's SUPPOSED to be doing ;)

Comatose 290 Taboo Programmer Team Colleague

I don't understand.....maybe you should attach the entire project. You only have 6 fields in the record (from what I can tell), so, how would you plan to add all the other stuff in the listbox? You'd need fields for those too, right? If you close in the modify portion, what do we see? UCase(lstAttach.Text), ok, it's using text again, and not list(0) or list(1) or list(list1.listindex)

Comatose 290 Taboo Programmer Team Colleague

You should do it in the keypress event of the textbox, check this thread: http://www.daniweb.com/techtalkforums/thread51931.html

Comatose 290 Taboo Programmer Team Colleague

Her last post regarding the project was Dec 30th 2004, I bet she's finished with it by now.

Comatose 290 Taboo Programmer Team Colleague

The above post may or may not work, depending on if the ID= portion of the string is NOT the first portion of the line... for example: hello;this is alineID=54678 and some stuff . If the line starts with the ID, then it will work to extract the ID portion and save the rest in a variable, but it won't extract the actual ID number. If you could post a portion of the .txt file, we could put together a much more efficient function for you.

Comatose 290 Taboo Programmer Team Colleague

I suggest stopping them from introducing anything other than numbers, right off the bat (in the text1 keypress event):

Private Sub Text1_KeyPress(KeyAscii As Integer)
'
' Invalidate keystroke if not a digit, decimal point or backspace.
'
If (Not IsNumeric(Chr$(KeyAscii)) And (Chr$(KeyAscii) <> "." And Chr$(KeyAscii) <> vbBack)) Then KeyAscii = 0

End Sub

And then test between the int or long variable types using vartype as so:

if vartype(retval) = vbinteger then
     msgbox "is integer"
end if

Here is a table of such data:

0   	vbEmpty   	Empty and not initialized argument
1 	vbNull 	        Invalid data or a null string argument
2 	vbInteger 	Integer argument
3 	vbLong 	        Long argument
4 	vbSingle 	Single argument
5 	vbDouble 	Double argument
6 	vbCurrency 	Currency argument
7 	vbDate 	        Date argument
8 	vbString 	String argument
9 	vbObject 	Object argument
10 	vbError 	Error argument
11 	vbBoolean 	Boolean argument
12 	vbVariant 	Variant argument
13 	vbDataObject 	Data Access Object (DAO) argument; an advanced database value such as a field or record
14 	vbDecimal 	Decimal argument
17 	vbByte 	        Byte argument
8192+int 	vbArray 	Array argument of the type specified by the int addition to 81920   	 vbEmpty   	Empty and not initialized

Now, as was stated above, a textbox will only return a string. There is no other means by which a textbox will contain data. A number, too, can be a string, "1" is a string, but it's a character that represents a digit. If you need a number in a specific variable type, though, you can "cast" it …

Comatose 290 Taboo Programmer Team Colleague

One Problem that stands out, is that the lstAttach is a listbox, and NOT a textbox. A listbox has a .text property, but it's basically there just to trick you. I wrote a test program, that has only 2 lines of code on form load. Which is: list1.text = "test" and then msgbox list1.text , and you'll see the msgbox is still blank. I guess microsoft had some lazy programmers, and just decided that if a certain control doesn't logically need a certain property, to just ignore it. If you want to add the item from the listbox, you have to know which item you want to add. A listbox is almost identical to an object form of an array, in that it has indices (indexes). If you want to know which item the USER selected from the listbox, you'll need to use something like this:

rs2.AddNew
rs2.Fields(0).Value = UCase(txtID.Text)
rs2.Fields(1).Value = UCase(txtDefineTask.Text)
rs2.Fields(2).Value = UCase(txtDocuments.Text)
rs2.Fields(3).Value = DTPicker1.Value
rs2.Fields(4).Value = CInt(txtDays.Text)
rs2.Fields(5).Value = UCase(txtNotes.Text)
rs2.Fields(6).Value = lstAttach.list(lstattach.listindex)
rs2.Update

What I've done, here, is changed lstAttach.text to lstAttach.list(lstattach.listindex). If the user has not selected any item in the listbox (meaning, no item is highlighted) then you can use numbers if you know which number you want to add. For example, to add the very first item in the listbox to the database: lstAttach.list(0) . I hope this helps to clear up some of the problem.

Comatose 290 Taboo Programmer Team Colleague

It's always a pleasure, welcome aboard and enjoy your stay.

Comatose 290 Taboo Programmer Team Colleague

Which, is basically what I said, without posting the code. If you are trying to bind the listbox to the database, though, that method will not work.

Comatose 290 Taboo Programmer Team Colleague

With a listbox, I'm pretty sure you have to do it all manually, for example:
1) Connect To Database
2) Query Database
3) Add Relevant info to listbox using the .additem method.

As far as making the listbox directly receive the recordsets.... I don't think you can.

Comatose 290 Taboo Programmer Team Colleague
Comatose 290 Taboo Programmer Team Colleague

I don't see why you can't just port over the code that's in the VBScript WSH. If you send me (or post the code) to the .VBS, I can show you how to import it into VB. Since you are using express, there may be minor touch up details that you'll have to fix, but the basis will be solid.

Comatose 290 Taboo Programmer Team Colleague

I have a pretty good idea of what you mean..... you don't want the new text file to just have ID's right? You want it to have ID's AND the information that is attached to those ID's..... but only the one's that have been selected by the GUI. right?

Please also post a portion of the .txt file that contains the ID's, so I can see the best method to go about parsing the data.

Comatose 290 Taboo Programmer Team Colleague

Private Sub btnClickMe_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClickMe.Click is a declaration type that is only acceptable in a .NET layout. The parameters passed are system event objects (system.object, system.eventargs) which doesn't exist in legacy VB, and beyond that, the "handles" keyword for the event doesn't exist in legacy VB. Those are strictly used in .NET or VB Express (which is actually .NET also).

As for his motivation..... who knows, maybe he's calling a script that someone else made, and doesn't want to try to port the entire thing..... we will only know if he chooses to answer that question.

Comatose 290 Taboo Programmer Team Colleague

Yikes on the thumb....

Firstly, I want it to be known clearly that you are NOT using Visual Basic.... the used the same name, but it's actually .NET or express, but not legacy VB. The Forum that you are posting in, is for Visual Basic from 6 and below.... you are using .NET.
Your question, however, is related more to the concept of programming than to a specific language, so I'm not going to move the thread. I don't remember exactly if .NET's textboxes use the .text property, or the .value property, but I'll post code for both. One problem that you are going to face is the fact that the script file, IS NOT part of your program, which means you will either have to pass it parameters, OR you'll have to set an option somewhere that the script reads when it runs.

The two ways are basically like this, to pass the parameter:
you would set the vbscript file up to read whatever is passed it on the command line, just like if you click start, go to run, and type in: notepad hello.txt you'll see notepad do something out of the ordinary.... if hello.txt does not exist, notepad will ask you if you want to create a new file. You can make your VBScript program take parameters also, so you could call it with something like:
myscript.vbs jerry
and then it would use jerry as the input to display in the …

Comatose 290 Taboo Programmer Team Colleague

Yeah, I think he was after a tooltip, like when you hold your mouse over a button and it tells you what it does.

Comatose 290 Taboo Programmer Team Colleague

Definately ADO. How well versed are you in the VB Language? A lot of times, people who understand little about programming at all want to take on pretty hefty tasks.... I'm not insinuating that you are doing that, I just want to make sure that I don't throw too much stuff in the mix that you haven't yet learned.... that said, I'll give a brief explanation of ADO.

ADO is a bunch of classes that allow you to make an object, so that you can connect to a database. You might only need one of the classes, or all of them. Anyway, the first thing you need to do is tell VB you want to use the database system. So, we go to up to the project menu, then references..... once the new window opens scroll down and find "Microsoft ActiveX Data Objects 2.5 Library" or the "Microsoft ActiveX Data Objects 2.6 Library". If you don't have them, your code will not work. Which means you probably don't have access installed on the box or something. Anyway, moving on.

Once VB knows we want to use those classes, we can make objects of them. So first, we need to define the variables that we will use to work with the database.

Dim conConnection As New ADODB.Connection
Dim cmdCommand As New ADODB.Command
Dim rstRecordSet As New ADODB.Recordset

The first line, is going to make a variable that will let us connect to the database. The second one, will …

Comatose 290 Taboo Programmer Team Colleague

It's possible that you are trying to create an instance of a class (an object) from a class that is present on the machines you tested it on, but not on the machine it's been deployed to..... for example, I happen to know that I can make a VB program utilize a class for Nero Burning Rom.... I can make a nero object, and use it's methods and properties...... but that will only work on machines that have the Nero libraries installed. If it's not installed, when you try to make the object (either through early or late bindings with new or createobject), the variable that SHOULD refer to the object is still set to Nothing, because the library failed to create an instance of the requested class.....

Basically, you are trying to make an object from a class that doesn't exist on the NT box.

Comatose 290 Taboo Programmer Team Colleague

I noticed there is no loop here, so I'm guessing that was excluded from the excerpt, OR you are only reading that info once..... is it possible for you attach the project along with a sample .bin file that you have so that I can trace through the code?