vb5prgrmr 143 Posting Virtuoso

Yes it is possible from within both visual basic and visual basic for applications as that is what you would use from within excel. If you go to the vba code window and press F1 and search for open workbook, you should be able to find some example code on how to do what you want to do. Then also perhaps, someone might come along and give you a few examples but if they don't, you can always use your friends (yahoo, google, ask, answers, bing) to search for vba open workbook or vba tutorial...

Good Luck

vb5prgrmr 143 Posting Virtuoso

By using the first of my friends (yahoo, google, ask, answers, bing) with a search of "vb6 rotate image" I found 2 decent links and one great link over to vbaccelerator... Which by the way uses GDI+ and a search of "vb6 GDI+" will result in a whole lot of useful information and even some specific information if you add the word tutorial...

Give it a try

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, first, if I remember correctly, you want to check to see if a record exists in your database before you do your insert right?... so that means you need to do a select statement first...

pseudo code
strSQL = "SELECT * FROM tablename WHERE fieldname = " & somecriteria
rs.open...

Now at this point, I have to say I'm sorry as I this vital piece of information... This check

If Rs.EOF = True AND Rs.BOF = True Then

is wrong as a recordset cannont be both EOF and BOF so this will always return false... it should be as I noted on pg3 post #23 (and below)...

Okay, so where was I... Oh yeah...

psuedo code
strSQL = "SELECT * FROM tablename WHERE fieldname = " & somecriteria
rs.Open strSQL, ...

If Rs.RecordCount <> 0 And Rs.BOF = False And Rs.EOF = False Then
  'record exists so notify user
  msgbox "record exists"
Else
  'no record exists so insert information
  sql = "INSERT INTO merchandise_table(mch_no, mch_name, mch_umsr, mch_qtyh, mch_uprice) VALUES('" & txtmchno.Text & "','" & txtname.text & "','" & txtumsr.text & "','" & txtqtyh.Text "','" & txtuprice.text & "')"
  commandobject.execute sql
  MsgBox "Record added"
End If

NOTE: Insert statement does not need/use a where statement.
ALSO: I wrapped each value in the values section in the above with single ticks as you had some of the fields either starting with a single tick or ending with a single tick, …

vb5prgrmr 143 Posting Virtuoso

With a quick glance... I don't see the relavent code that shows where you detect the collision of a ball with a brick. I see the walls but not the ball hitting the brick...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Well considering that the "Text" in text1.text is "Text" to begin with there WebSpoonUK, your code shows how vb coerces values from string to number without explicit conversion (iIntegerVariable = Int(Text1.Text)). So, your code can be shortened to just...

Text2.Text = Left(Text1.Text, 1)
Text3.Text = Right(Text1.Text, 1)

Furthermore Devsof, setting the max length property of text1 to 2 will prevent more than two characters from being entered into the text box but that will not prevent other characters than numbers from being entered. BUT that can be fixed with the following...

Option Explicit

Private Sub Text1_KeyPress(KeyAscii As Integer)

On Error GoTo Text1_KeyPressError

If KeyAscii = vbKeyBack Then Exit Sub
Select Case KeyAscii
Case 48 To 57
Case Else
  KeyAscii = 0
End Select

Exit Sub
Text1_KeyPressError:

MsgBox "Text1_KeyPress " & Err.Number & ":" & Err.Description

End Sub

Good Luck

vb5prgrmr 143 Posting Virtuoso

Yes, use GDI+ (friends time again) vb6 gdi alpha, vb6 gdi briteness...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Correct, it is best to use the insert into statement when you can over the .addnew method, so don't use both to insert a record, one or the other...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Trim(Text1(0).Text) is the index of a textbox array...

.addnew = add new record
no .addnew = edit current record

Good Luck

vb5prgrmr 143 Posting Virtuoso

Wrong, each computer that connects to a server/service like SQL, Oracle, etc, needs an ODBC DSN if you are not using ADO's DSN Less capability. Having a ODBC DSN on just the server will not work...

Good Luck

vb5prgrmr 143 Posting Virtuoso

An ODBC DSN (Open DataBase Connectivity Data Source Name) must be created on each computer that will use the end result of the Visual Basic 6.0 design process. Meaning you create the exe and the installable package and install the program on the machine and then create the ODBC DSN...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Don't think so, but then again I don't go up against 2k5 very often...

Now, in the example above, your select *..., if you are calling that a stored procedure, then you have your terminology wrong as that is a select statement and you need to use a recordset object pretty much as you are but if I remember correctly, there are some additional parameters missing from that open statement...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Time to look into the API... keybd_event, sendinput, and so on...

Good Luck

vb5prgrmr 143 Posting Virtuoso

If a SP returns some sort of results (T/F, recordset) then use a recordset as you are. If it just does something use a command object...


Good Luck

vb5prgrmr 143 Posting Virtuoso

The text box does not directly support superscript or subscript but with a little know property of the RTB you can accomplish what you want...

Or at least most of it...

Option Explicit

Private Sub Form_Load()
RTB.Text = ""
RTB.SelStart = 0
RTB.SelText = "2"
RTB.SelStart = Len(RTB.TextRTF)
RTB.SelCharOffset = 60
RTB.SelText = "7"
RTB.SelCharOffset = 0
End Sub

As for the not equals sign, you are going to need to see if a font has that character in its list (I check arial, courier new, webdings, and all three wingdings...) or you might be able to insert a small gif at that point...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Right Click>run as admin or the use of a manifest file that requests higher privileges may work for you. See M$ and the web for more info...

Good Luck

vb5prgrmr 143 Posting Virtuoso

When that dialog pops up, click on debug and VB will take you to the error. Correct the error and try again. Also, goto Tool>Options and put a check next to require variable declarations. Then on the general tab, select break on unhandled errors. Then at the top of every code window, paste in Option Explicit. This will force you to declare your variables and raise errors as you debug in the ide.

As for making a VB exe a stand alone... Well more than likely that ain't gonna happen. You will need to create an install package. Best bet is to use windows installer 1.1 or inno which are both free. For windows installer you can find a link to download it under to top pinned thread to this forum, the one titled tutorials, tips and tricks or something like that.

As for running on any system, VB will not run on linux unless it runs under the Ruby (?I think that is the name?) emulation. Same goes for Solaris and Mac has a windows emulation also.

As for window systems, a lot of what you create can be run on win95 and up unless you use certain things that are not normally availiable to these earlier systems, like a lot of the API's especially those that make the form transparent.

Then starting with win 2k or was it XP? I think it was XP SP1 that allowed for the use of side by side …

vb5prgrmr 143 Posting Virtuoso

Walt, I'm not sure if I should laugh at that or just smile :)

Ben, time to get out the old mark I recording and documentation devices and use then to design your system (BTW, that would be pencil and paper).

Good Luck

vb5prgrmr 143 Posting Virtuoso

I don't have your code handy at the moment but lets say you have three text boxes that contain a number, text, and date and they are also an array of text boxes...

strSQL = "INSERT INTO tablename(numericfieldname, textfieldname, datefieldname) VALUES(" & Trim(Text1(0).Text) & ", '" & Trim(Replace(Text1(1).Text, "'", "''")), & ", #" & Text1(2).Text & "#)"

Now, as you can see, the first field that is a numeric field is not surrounded by single ticks (') while the text field is. Also, you can see the replace function that replaces single ticks contained within the text to be inserted with two single ticks ('>''). Now, what this does is it takes a word like don't and transforms it into don''t, but when it is inserted into the database, the database recognizes this as the word is supposed to have a single tick in it. So the database takes don''t and transforms it back into don't so when you pull the value back out of the database, you get what you want don't. Then as you see the third field is wrapped by pound symbols (#), which indicate to access (and access only) that a date is being passed to be inserted (Note: other databases will accept a string value and convert it to a date for you but access will not accept a value wrapped by single ticks and as such must be wrapped by the pound symbol).

Good Luck

vb5prgrmr 143 Posting Virtuoso

Lets see, you want to use Access the application as the front end to a Visual Basic 6.0 back end???? Are you sure you don't have that backwards???? I mean it can be done.... but one would have to ask why???? Or are you talking about VBA??? So confusing it can be when one does not proof read what they are writing...

Because normally Visual Basic 6.0 is the front end and the Jet engine (The Access application is a front end for the jet engine also...) is the back end...

So lets get you to repeat exactly what you want to do and what you have done so far to accomplish your goals...

Good Luck

vb5prgrmr 143 Posting Virtuoso

To hide rows and columns in a "bound" data grid, you use the select statement to restrict the number of columns and the where clause of that select statement to restrict the rows returned and finally use the option order by keywords to order the returned data. Otherwise, using your friends (yahoo, google, ask, answers, bing) and searching for vb6 data grid tutorial will find you all the answers you need.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, around line 69 above, you would build your insert string and use either your command or connection object to execute the insert statement. So what you do is this...

strSQL = "INSERT INTO tablename(list fields here seperated by commas) values(now in the same order as the field list and seperated by commas you list the values you want to insert for each file and as noted above wrap strings with the single ticks number are not wrapped by those single ticks and date are wrapped by pound signs)
adoCn00.Execute strSQL

Now that is the best way to do an insert...

However you can do the rs.addnew/rs.field("fieldname").value = text1.text/rs.update starting at the same line number but this takes longer and can cause problems with multiuser systems depending upon the cursor type...

Good Luck

vb5prgrmr 143 Posting Virtuoso

That is after you take a picture (friends time (yahoo, google, ask, answers, bing) vb6 snapshot) of the textbox as a text box will not rotate in itself.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Hey bob, look up the URLDownloadToFile API and then you will know how to do that save as portion without the need for user intervention (the right clicking and selecting save as and selecting the directory and file name...)

vb5prgrmr 143 Posting Virtuoso

Okay, there are three different insert into statements. One of them will create a new table from and existing table, another will insert records from another table into an existing table, and the third will simply put information into a table, I believe this is the one you want. The other two you can create through the access designer...

strSQL = "INSERT INTO tablename(stringfieldname, numericfieldname, datefieldname) VALUES('" & stringvariable & "', " & numericvariable & ", #" & datevariable & "#)"

Note: in the future, you will find that access is the only database that requires the date to be surrounded by the pound symbol (#).

Good Luck

vb5prgrmr 143 Posting Virtuoso

Yes we may be able to help you but without knowing what the code is, the err.number and err.description,... well presently we are clueless as how to help you....

Good Luck

vb5prgrmr 143 Posting Virtuoso

Not sure if you can delete it... Post that or search first in the daniweb community feedback forum and if you don't find an answer, then post in that forum...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Time to use your friends (yahoo, google, ask, answers, bing) and search for vb6 mask color, as I believe you will need to make the second graphic only show the information. Or you mignt want to search on vb6 transparent picture box if that effect does not accomplish what you want. Then again, you could search on vb6 bitblt API or in help the paintpicture function and click on see also to select rasterop constants...

Good Luck

vb5prgrmr 143 Posting Virtuoso

You need an inner join statement in your from clause... The easiest way to get this correct is to use Access's query design window...

So go to the query tab/window of access and double click on create query in design view. Add the two tables when the window pops up. Now, from here you can either select all the fields or just that * symbol. From here you can check the result by selecting datasheet view, but the view you are after is the SQL view.

What you should see is something like this (but it may have more parens)

SELECT student.*, marks.* FROM student INNER JOIN marks on student.roll=marks.roll

Now copy this from access to vb and you are done! And just so you know, access's query design tools are great to design some of your more complex queries and as you can tell, it allows you to see instantly if you are getting the results you are expecting.

Also, another note. When it comes to the field that your tables are joined on, you will need to prefix the field with the table name...

txtRoll.Text = Rs.Fields("student.Roll").Value

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, I see now... Knew it as a junction point but after reading about it so long ago quickly forgot about it as at the time I never saw a good use for it, so I guess I have relearned something and learned something new today! Yeah! I'm done! :)

Okay, from here I'll step out of the way...

Good Luck

vb5prgrmr 143 Posting Virtuoso

An easy way is to use the API URLDownloadToFIle...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Are you talking about shortcuts? *.lnk files?

vb5prgrmr 143 Posting Virtuoso

Yes it is possible but you should be looking for an ASP forum and/or a VBS forum...

Good Luck

vb5prgrmr 143 Posting Virtuoso

You are using VBA and NOT VB6.0. VBA is an interpreted language while VB6.0 can be compiled to native binaries (exe's, dll's, ocx's, etc.). So yeah, looking in Visual Basic 6.0 forums, your going to find a whole lot of functionality that VBA does not support... at least right off on a lot of it and it is very understandable why some people get confused between the two because they do share the same basic code base.

So, in the future you might want to look for VBA specific coding forums or Office forums for some things, but because the languages are so similar, usually you can get your answers from VB6.0 forums.

Now, to your specific problems...

A VBA form does not expose a hwnd as it is an interpreted and hosted form but you can add certain controls that do have a hwnd, but also because it does not expose a hwnd, it does not expose a windowstate and thus an icon in the appbar. The menu editor, is specific to to VB6.0 but that does not mean you cannot create your own menu with some tricks.


Good Luck

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

Normally you Raise custom errors from a class and when you do so the error is pushed back to the calling function, which in turn should have an error handler to handle it.

As an example, here is something you could step through with F8...

Option Explicit

Private Sub Form_Load()

On Error GoTo Form_LoadError

RaiseMyError

Exit Sub
Form_LoadError:

MsgBox Err.Number & ":" & Err.Description & " in " & Err.Source
End Sub

Private Sub RaiseMyError()
Err.Raise vbObjectError + 1, "Form1", "This is a test of raising an error"
End Sub

Good Luck

vb5prgrmr 143 Posting Virtuoso

Is this code you are talking about or a compiled activex dll or a c dll?

If code, start a new project and add the class to it. Then write code to instantiate it and test it.

ActiveX, add a reference to it in a new project and write code to test it.

C Dll, then you will need the API declarations to test it...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Huh?

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

No, thank you neosonic for searching out other threads and information that allowed you to solve your own problem :)

Good Luck

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

Not a problem,... For future reference if you want to print things in colums, by not using spc or tab, build your output string before sending it to the printer...

Dim S As String, I As Integer
Printer.FontName = "Courier New" 'makes it easier to use mono spaced font
S = "Test Col 1" 'so far left aligned
'now next column is to be 40 characters from left but the colum is to be right aligned and the column is 3 characters wide (so positions 41-43)
I = 41 - Len("Test Col 1")
S = S & Space(I)
I = 3 - Len("12")
S = S & Space(I) & "12"
'and so on
Printer.Print S

However, that code can also be done like this...

Printer.Print "Test Col 1"; 'so far left aligned (it is the ; character that says not to goto the next line)
'now next column is to be 40 characters from left but the colum is to be right aligned and the column is 3 characters wide (so positions 41-43)
I = 41 - Len("Test Col 1")
S = S & Space(I)
I = 3 - Len("12")
Printer.Print Space(I) & "12";
'and so on

and another way would be to use the currentx/y properties (as I think I mentioned before)

Glad you solved it...

BTW, set for autoredraw to true and remove the printer part of printer.print and you can see a preview of what your output is like but once again you …

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

Once again, I suggest the use of the common dialog control for showfont, showcolor...

Good Luck

vb5prgrmr 143 Posting Virtuoso

I'm betting that if you step through that code with F8, you will find your error at the line control.index = 0, because at that point, it has not been created yet...

Also, if you want to create controls and have them in an array, then you need to set the control on the form at design time and set its index to zero and load copies from there...

Another Also, the reason we have control arrays is because several controls can have the "SAME" name, i.e. Label1 and each is then referenced by its index number (0), and the reason I bring this up is because you are naming controls ttbco_0, ttbco_1 and as such they are not considered an array because each control as a seperate and unique identifier...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Time to use your friends (yahoo, google, ask, answers, bing) and search for vb ado turorial. Once you have that under your belt, then go over to http://www.connectionstrings.com to look up the DNS Less connection string format you will need to use to connect to Oracle 9i...

Good Luck

vb5prgrmr 143 Posting Virtuoso

several different ways... Look in properties where is says windowstate. set it to vbmaximized or if form load me.windowstate = vbmaximized or me.width/height = screen.width/height and a few more ways...

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