
Hi All
I am working on a vb 6.0 + MySQL project.
I need to create a Database(for local use Ex: If user wants to create database they can create and dump data from online databas) Dynamically and restore the database with production database backup.
Is it possible?
Thanks,
Willington D





Yes.. it is.. (As long as you code it)
Do Or Don't, there is no "try catch ex as exception end try"





Why in VB 6.0?
Surely you have VB.Net?
VB 6 is deeply unsupported, whereas VB.Net is not only supported but has more inbuilt sql connectivity.

"Children today are tyrants. They contradict their parents, gobble their food and tyrannize their teachers. I despair for the future."
Socrates 400BC





Hi Guys,
not sure if im in the right forum but this is the error i am getting in my script.
i have googled and tried many things but to no avail....
the error:
"Object Required: WScript"
the code:
dim wshShell ,Wscript
set WshShell = CreateObject("WScript.Shell")
while StockCode <>""
Wscript.Sleep 1000
wend
the error fails on Wscript.sleep command...
any idea on how to solve this....
thanks in advance
Anoop





You create WshShell in line 2 but never create Wscript!
Never underestimate the power of human stupidity
RAH





how do i do that? i.e. create the wscript?
thanks





The same as you did for wshscript.. but i'm guessing this is copy past. Brushing up on OOP could help a lot more ..
Do Or Don't, there is no "try catch ex as exception end try"





It's obvious you have no clue what you're doing. I suggest starting with the basics, here[^].





I'm looking for some help with computing values of a triangle and then drawing it to screen
Known;
Two points in degrees exist on a circle
Two line lengths representing ;
base, adjacent side (a)
and
opposite (c)
we want to derive side (b) hypotenuse
and also angles (A), (B), (C)
We already know that sides (a) and (c) join and we know that the longest side length will not exceed the diameter of the circle that the triangle is circumscribed within
The triangle created will be variable as different degrees and side lengths are entered, typically this will be scalene triangles but the may also be at times right triangles
I've been using a derived arc cos function ;

Public Function Arccos(X As Double) As Double
Arccos = Atn(X / Sqr(X * X + 1)) + 2 * Atn(1)
End Function

I know we can convert degrees to radians via "* Pi) / 180"
I know I can get the hypotenuse by;

side_b_squared = CDbl(c1 ^ 2 + a1 ^ 2  (c1 * a1)) * Cos(angle_B_degree_value_radians)
b1 = Sqr(side_b_squared)

I know we can get the angles A,B,C via ;

angle_C_cos_value = CDbl(a1 ^ 2 + b1 ^ 2  c1 ^ 2) / (2 * (a1 * b1))
angle_B_cos_value = CDbl(c1 ^ 2 + a1 ^ 2  b1 ^ 2) / (2 * (c1 * a1))
angle_A_cos_value = CDbl(b1 ^ 2 + c1 ^ 2  a1 ^ 2) / (2 * (b1 * c1))
angle_C_acos_value = (Arccos(angle_C_cos_value))
angle_B_acos_value = (Arccos(angle_B_cos_value))
angle_A_acos_value = (Arccos(angle_A_cos_value))
angle_C_degree_value = angle_C_acos_value * 180 / Pi
angle_B_degree_value = angle_B_acos_value * 180 / Pi
angle_A_degree_value = angle_A_acos_value * 180 / Pi

Although, I've had some trouble with this since some of the returned angles for some previous testing I did didn't
seem to be working very well, for instance I'd enter 60 degrees for angle (B) but it would somehow crunch it to
angle_B_Degree Value 38.8700377933938
I'm a little stuck on the math for all this.... here is an example scenario that I hope illustrates really clearly what I'm trying to do ;
A small VB app does the following ;
A small circle is drawn to the screen
On the form of the VB app there are text boxes that accept inputs ;
Text 1 = side (c) length as a number
Text 2 = side (a) length as a number
Text 3 = a value in degrees that represents a point of one of the ends of side (c)
Text 4 = a value in degrees that represents a point of one of the ends of side (a)
Then the following are computed ;
side length of the hypotenuse as a number, and output to a different text box
Angles (A), (B), (C) are computed as values in degrees, and output to another text box
The drawn circle may be say four inches in diameter, and all side lengths computed, regardless of their number value
are fit proprotionally, circumscribed within the circle, so even if one of the side lengths is really long, all side lengths are fit proportionally in the circle but retaining the same intrinsic unit measure values of their lengths.
Any help or insights on the above are really appreciated, especially the math and formula end and any code ideas, samples are a God send.
I'm a bit of a newbie with all this and I'm using an older version of VB (4.0)
I have a basic idea on using some of the draw functions and I think I can tinker my way through this, but again am very open to any feedback
Thanks people!





It would help if you stopped using the term Hypotenuse, as this only applies to Right Angles.
Also, is the radius known or unknown?

"Children today are tyrants. They contradict their parents, gobble their food and tyrannize their teachers. I despair for the future."
Socrates 400BC





Ok, will stop using the term hypotenuse!
Also, the longest triangle side will never exceed the diameter of the circle, but here are some more notes that may be helpful in better understanding what I'm trying to do ;
The triangle, circumscribed within the circle is situated so that each point of the triangle must fall somewhere on the perimeter of the circle itself For example sides 'a' and 'b' both have one of their ends at the centerpoint of the circle, and the angle between them is angle 'C'
What Im hoping for here, is that the circle centerpoint is not used at all, so no ends of the triangle will everland there
There needs to be actually four inputs... I know this sounds a bit unorthodox, but here is the interesting part of the problem... I'll clarify this.....
We want two inputs that store the lengths of two of the sides of the triangle ;
Text 1 = side (c) length as a number
Text 2 = side (a) length as a number
We also want two inputs that store two values that are points on the perimeter of the circle in degrees
Text 3 = a value in degrees that represents a point of one of the ends of side (c)
Text 4 = a value in degrees that represents a point of one of the ends of side (a)
So in the end we know that we have two sides of specific lengths that must fit within the circle, and we know that one of the ends of each line is connected to a specific degree point on that circle, we also know that both these side lengths do join somehow somewhere, but the degrees that are input ARE NOT the angles of any part of the triangle, here in this case, the degrees that are input are ONLY points on the circle itself that are simply where the lines of each respective triangle, so for example
A circle of four inches diameter
a line length of 10 units has one end point at 30 degrees
a second line length of 8 units has its end point at say, 78 degrees
where does the third point fall on the circles perimeter? at what degree?
what is the line length of the missing side, and then what are the angles contained within the triangle....
This is the math, code part I am hoping for help on..... I hope this clarifies?
Also... I'm using VB 4.0 and can't upgrade for a while  long story





Rockoon!
Thank you so much for your reply!
I just realized I made an assumption that may not be correct at all.
I had thought earlier that if we knew two points in degrees on the circle, then the difference or sum between them must be either one of the values of the unknown internal angle, or at least it would represent the other 3rd unknown point on the circle.
Now I'm thinking that, thats just a poor guess on my part!
Although, I then realized that if we knew two of the lengths of two of the sides, and if we knew that each line was associated with one of the points, then one of the lines must also intersect the two known points, and since that is the case then if the line that joins the two points is not equal to either of the two known line lengths then that gives us the missing side!?
If thats the case then its a matter of deriving where the third unknown point in degrees on the circle would be where the two known line lengths would meet?
I'm guessing, but if I'm not mistaken there could only be a maximum of two specific points on the circle where these two lines could join? But maybe only one place?
I'm hoping there is a way to 'algebratize' all this and then code it!?
Also, this is really important I feel ;
The lines of the triangle will be variable and in generic units, but say we know that the diameter of the circle is four inches. Line lengths may be values of 10, 23, 5, what ever... but they will fit proportionately in the circle, so the lines of generic unit measure need to be fit within the circle.
Here, we only know two of the points on the circle
In this exercise we don't know any of the internal angles, all we know are two points in degrees on the circle (the third is unknown) and we know that each point will be associate with one of the two known line lengths
We have the following unknowns;
All three internal angles, and one of the side lengths
All we know is two side lengths, two points on the circle in degrees where each point is associated with one of the side lengths, and we know which point on the circle is associate with which line,
We also know that the two known points on the circle must join and that this line may or may not be one of the known lines. Some sort of check, if statement could verify it when measured proprtionately somehow and if its not one of the known line lengths then we have our third unknown line





If you only know two side lengths of a scalene triangle (but none of the angles) can you determine the third side length?
I had been using this formula to determine the length of the hypotenuse ;
SQRT ( side1^2 + side2^2)
But realized that this is meant ONLY to determine the side length of the hypotenuse for right triangles and not scalenes per se.... is there some other formla that can be used to get the line length of the hypotenuse for a scalene in the above situation?
If there isn't a way to get the 3rd line length of scalenes this way, do you know if there is a way to get the hypotenuse line length AND the angle between the hypotenuse and the base, if we have the two side lengths of the base(adjacent) and the opposite side, and if we have the associated angles for these sides?
I've tried to incorporate all I've learned so far... but I keep getting weird errors and as far as I can tell all my formulas are correct?
I've built a small VB program, am including a sample below and the critical formulas and code I'm using... if any one can shed some light on where I've gone wrong it would be so nice!
( I'm using VB 4.0 and can't upgrade right now so I have to work within that limitation)
Here is an example ;
Accept input from three text entry boxes
1.) Value for Side (a), Adjacent Base
the value of 14 is entered
2.) Value for Side (c), Opposite
the value of 10 is entered
3.) Angle (B) [ entered as degrees ]
the value of 60 degrees is entered
The hypotenuse is computed to be ;
8.83176086632785
The arc cos function is derived ;
Public Function Arccos(X As Double) As Double
Arccos = Atn(X / Sqr(X * X + 1)) + 2 * Atn(1)
End Function
Its then called from code below
Pi is declared as a constant in a module
'=======================
'=======================
'Converts the entry from degrees to radians
angle_B_degree_value_radians = (angle_B_degree_value * Pi) / 180
'get hypotenuse side length and outputs it to a text box
side_b_squared = CDbl(c1 ^ 2 + a1 ^ 2  (c1 * a1)) * Cos(angle_B_degree_value_radians)
b1 = Sqr(side_b_squared)
Text5.Text = b1
angle_C_cos_value = CDbl(a1 ^ 2 + b1 ^ 2  c1 ^ 2) / (2 * (a1 * b1))
angle_B_cos_value = CDbl(c1 ^ 2 + a1 ^ 2  b1 ^ 2) / (2 * (c1 * a1))
angle_A_cos_value = CDbl(b1 ^ 2 + c1 ^ 2  a1 ^ 2) / (2 * (b1 * c1))
angle_C_acos_value = (Arccos(angle_C_cos_value))
angle_B_acos_value = (Arccos(angle_B_cos_value))
angle_A_acos_value = (Arccos(angle_A_cos_value))
angle_C_degree_value = angle_C_acos_value * 180 / Pi
angle_B_degree_value = angle_B_acos_value * 180 / Pi
angle_A_degree_value = angle_A_acos_value * 180 / Pi
'=======================
'=======================
The problem is, that
angle_B_Degree Value 38.8700377933938
is returned as a degree value very different from what I entered ( 60 ) degrees! I wanted to recompute this angle to confirm that it was working ok.... but it seems often off, so now I dont know how valid any of my calculations are! I don't understand why this is happening?
I've also tried entering angles different from 60 degrees but with the samed side length values, for instance if I enter 90 degrees or 120 degrees it jus automatically fails.... if I enter 80 degrees I also get an error back....?





Without angles, no.
There is a maximum length for the third side, which is the sum of the lengths of the other 2 sides.
Imagine a pair of compasses, the length of the two legs is fixed, but the third length can be changed bu pushing them apart or pulling them together, so length of two sides does not give length of third.
Euclidian Geometry and Pythagorean Maths are a pain yes?

"Children today are tyrants. They contradict their parents, gobble their food and tyrannize their teachers. I despair for the future."
Socrates 400BC






Without knowing the angle between the two known sides, either directly or computed by other means, it's impossible to determine the length of the third side.





How could I display font in a combo1 (and size in combo2) showing them the font and size of the richtextbox (rtfText) on the cursor position basis?
They already show fonts and sizes existing in the system font, but I should want to add code to show which font and which size is running moving cursor all aroung the text.
On form_load I have
Dim i As Integer
' Declares an integer 'i' for the multiple purposes
' User selects the font size from this combo box
For i = 8 To 12
cboSize.AddItem i
Next i
For i = 1 To Screen.FontCount  1
If Screen.Fonts(i) <> "" Then cboFont.AddItem Screen.Fonts(i)
Next i
BUT NOW? Thanks in advance.





Your question isn't very clear at all. Are you asking how to set the font at the cursor position or change the font of the selected text in a RichTextBox??





You need to write a handler for the change event of the RTFTextbox. There you read the current font properties and update your selected items in your comboboxes accordingly. If it slows down your app too much you can try to use a timer control, to loosen the coupling of updating the comboboxes and the movement of the cursor.
Regards: Didi





I need to write debug outputs and general log file data to a log file.
There may be several instances of the application that needs to write this data running at the same time, processing different data sets. I need to collect the outputs into a single shared log file that will be appended to.
I thought that the simple way would be for each instance to create a logfile with a unique name, then when the application is done, it would spool the content of it's own unique log file to a system printer that used the FILE driver. In this way I thought I could avoid writing a spooler of my own.
The problem that I haven't yet overcome is that the print to file driver pops up a window asking for the output file name each time it is called. I'm not sure whether the shared/spooled write access I seek will work even after I get past this problem.
There may be a much simpler way to do what I am trying to do, but I haven't found it yet.
For an ancient assembler/Fortran coder like me learning how to use the extreme richness of VB 2008 reminds me of an old text based dungeons and dragons game.





So what's wrong with just every instance of the app writing to the same log file?? It's easy enough to pull off. Just open the file, write the message, and close the file. But, there's a little catch. Keep attempting to open the file DenyShareAll until it actually opens. It shouldn't take very long at all if your messages are short.
Another possibility is a service or other server app that listens for messages comming from your app. All instances of the app talk to the same instance of the loggin component, that itself writes to the log.
Using the print FILE driver is a bit too much for such a simple operation.





Thanks for the help Dave. I adapted the DenyShareAll methodology  I'm using a Streamwriter to send the text to the file and I couldn't find a DenyShareAll property for it so I'm simply catching the IOEXCEPTION when it tries to open the file, waiting 500 ms and trying again till I get access. Seems to work so far.
I'd prefer the inter process comms model (as a purist) but I didn't feel like learning how to use named pipes or some similarly complex substitute today. Maybe tomorrow





Roy Barkas wrote: I'm using a Streamwriter to send the text to the file and I couldn't find a DenyShareAll property for it so I'm simply catching the IOEXCEPTION when it tries to open the file, waiting 500 ms and trying again till I get access. Seems to work so far.
That's how you're supposed to do it!
Roy Barkas wrote: I'd prefer the inter process comms model (as a purist) but I didn't feel like learning how to use named pipes or some similarly complex substitute today. Maybe tomorrow
That's how I learned how to do this stuff. Just write little examples that do nothing but what I need.





Hi all,
i am fetching float value from SQL
select instanceid2400,CAST(weight as float) as GrossWeight from .....
but when i am reading it
Private Sub Fetch(ByVal dr As SafeDataReader)
'Load object data from the Database
With dr
_GrossWeight = .GetDouble("GrossWeight")
where _GrossWeight has also datatype as double
it's not working fine
similarly when i change my query to
select instanceid2400,CAST(weight as int) as GrossWeight from .....
_GrossWeight = .Getint32("GrossWeight")
it works fine
what can be the solution
Ankit Aneja
"Nothing is impossible. The word itself says  I M possible"





Ankit Aneja wrote: With dr
_GrossWeight = .GetDouble("GrossWeight")
where _GrossWeight has also datatype as double
it's not working fine
So what IS the result?? Are you getting a value?? What is the expected value and what is the actual value returned?? Is there an error message??




