|
|
hmm
Private Sub HighlightText(ByVal Highlight As String)
what's that for?
|
|
|
|
|
|
I'm trying to find a safe way to put a delay of 4 seconds in my code in VB 6.0 (NOT .NET). This is the code I have:
Public Sub Wait()
i As Integer
Halt = 4
Dim LTime
LTime = Timer()
While Timer() - LTime < Halt
i = 1
Wend
End Sub
This works great except for one problem. If I am running a form, press a button that calls this function, and then close the form before this function is completed, the visual of the button is corrupted. Basically, when the draw window is called (IE with a form.show call), the button shows through to the background and saves that image at its interface. IE If I have a word doc behind it, close the form with wait in progress, and form.show the form, it will bleed through with the button with whatever text is in the box of the button. How do I fix this?
Thank you,
Red Sunday
-----------------
http://www.zachcalvert.com
|
|
|
|
|
Hi Red!
I'm trying to find a safe way to put a delay of 4 seconds in my code in VB 6.0 (NOT .NET).
First, don't use While...Wend to loop. Use a Do loop instead (see also How to Use Looping Structures in Visual Basic for Applications[^]). Second, don't use a loop at all. You can use Task-Manager to quickly find out that your loop will lead to 100% CPU usage. Use the API function Sleep instead.
Option Explicit
Public Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Integer)
Public Sub Wait()
Sleep 4000
End Sub
You can find more about Sleep and an API function called SetWaitableTimer (which might solve your re-draw problem) in the article How To Use SetWaitableTimer With Visual Basic[^].
Best regards
Dennis
|
|
|
|
|
depending on what you are trying to do, there are two main options:
1. Causing the Code to completly halt
can be done by using the Sleep method (i saw you got a got overview of it)
or by looping like you did
BUT - add a DoEvents() call inside the loop, this will allow the window to redraw
this approach of halting is not very safe to begin with, especially in VB6 that runs
EVERYTHING on a single thread.
you might want to try these two approachs:
2. Timer based halt.
Create a timer object, and set it to start timing you in the 'Wait' method
handle the timer's "Timer" event, in the hanlding sub
a. disable the timer
b. call a method to continue the operation
there are additional ways to achieve this, but i think this will get you going
Fade (Amit BS)
|
|
|
|
|
I had copied data from datatable A into datatable b by using the "datatable.copy" function. I was wondering if anybody can tell me if after the copy, the rowstate in datatable b will change to "Added". If not, can you show me how to add rows from one table to another row by row? Will this way then change the rowstate to added? I am just a beginner so I am sorry if this question seems trivial to some.
Thanks in advance!!!
|
|
|
|
|
I want to Restrict Websites on IE through a LOG file eg XML all the restricted websites will be given in that XML file and whenever a user open on my pc the site my program will check that whether it is restricted site through checking XML file
Please help me out ..
Thanx in Advance
R A M RIz
|
|
|
|
|
I know and understand math operators in vb.net. I am only using vb.net. I create a math windows application but cannot get the gist of using fractions. In the like using a fraction to retrieve a result in fraction.
(e.g. 1/4 + 1/8 = 1/2). Can anyone help in this instance of programming with fractions in Visual Basic.Net. The language is not written in C# or vb6, but in visual basic.net.
bravo659
|
|
|
|
|
Dessi Bravo wrote:
1/4 + 1/8 = 1/2
You mean 3/8
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Yeah I meant 3/8. Would anyone know how to convert this from a decimal to a fraction, or fractions only?
bravo659
|
|
|
|
|
Hi please help with code to use a picturebox control or image control to display a photo from an access db the field name is photo and the datatype is memo. How can it contain the string character? When i try this code picturebox1.picture = stu("photo") i receive a datatype error.
thanks
|
|
|
|
|
This shouldn't be a memo field, but an OLE Object field.
I am assuming that you want to display a photo IN an Access form or Report, not FROM an Access database.
In any event, Access won't take the image into the database unless the field type is OLE Object. Once you use this object, you will get additional controls to import images into the record.
You won't need to code this either.
mmcdonald
|
|
|
|
|
i want to open cash drower when i print a report how should i do this using
Com port or LPT port.
can any one help me out there.
thanks.
|
|
|
|
|
Just a quick guess, but have you tried just printing a ^G (Control-G) to the printer port the drawer is connected to?
The last set of cash drawers I worked with were triggered by a simple bell character (Control-G) being sent to the LP port.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
I have an assignment at school and I need to take a comboBox and make the contents of it into an array(regular,Premium, Super)and a numericupdown box that goes from 0 to 100 and 2 textBoxes and do the following.
when the the numericupdown box's value is changed it will put that value into a txtBox (like a gas pump) and then in the other txtBox it will take that value from the first txtBox (that is connected to the numericupdown) and muliply it by the value of regular(which is .90)and so forth and so on with the Premium(1.00) and the Super(1.10). I don't know how to do it. I have gotten the value of the numericupdown to show in the first txtBox but I don't know how to get them to multiply. I keep getting and error of cannot convert a String to a double and I don't know how to correct it.
this is what I have:
Dim Gas(3) As Double
Private Sub nudValue_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudValue.ValueChanged
txtValue.Text = CStr(nudValue.Value)
Gas(0) = 0.9D
Gas(1) = 1D
Gas(2) = 1.1D
txtGasTotal.Text = txtGasTotal.Text * txtValue.Text
End Sub
Am I on the right track or completely of course.Please help.
|
|
|
|
|
Try this:
txtGasTotal.Text = (CDbl(txtGasTotal.Text) * CDbl(txtValue.Text)).ToString
I bet you have Option Strict enabled and that does not allow implied type conversion like VB6 used to. You have to explicitly convert before doing the math.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Yes I do have Option Strict On. I tried the code that you suggested and it didn't work. I keep getting an error that says "disallows implicit conversion from double to String." If there is any other help that you could give me I would greatly appreciate it.
|
|
|
|
|
Ok, not qwuite sure what you are traying to do here but I just typed in this code and it worked fine (no conversion errors).
Private Sub nudValue_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudValue.ValueChanged
txtValue.Text = CStr(nudValue.Value)
Gas(0) = 0.9D
Gas(1) = 1D
Gas(2) = 1.1D
txtGasTotal.Text = CStr(CDbl(txtGasTotal.Text) * CDbl(txtValue.Text))
End Sub
This will also work:
txtGasTotal.Text = (CDbl(txtGasTotal.Text) * CDbl(txtValue.Text)).ToString
In the second sample play close attention to where the parens are. It makes a difference.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Is there a way to get the source code from axWebbrowser.
I have a web site that get a cookie for me where i go to it. I want to be able to get the source code.
I'm have tried WebRequest but this doesn't send the cookie it need to log on the their web site.
The source code i get from the WebRequest is to log on to the web site.
I want the source code of a page that i have to send a cookie to log on to see the right source code.
Can any one Help
Tdaigs
|
|
|
|
|
I need help here. Usually in the old VB6 world, I used the standard ado connectivity to connect to to my Oracle Databases, with Oracle Client installed on my box, system DSN entries and a TNS Names File.
I am now attempting to connect to my Oracle DB through VB.Net and the System.Data.OracleClient because I need to take advantage of a stored proc that returns a cursor. All examples of connection strings for the OracleCleint.Connection are akin to "Data Source=Oracle8i;Integrated Security=yes" or "Data Source=Oracle8i;User Id=userid;Password=pwd". This is not helping me at all. On the server I need to connect to there are 3 Oracle 9i servers running. Each with its own sid. I have tried things like "Data Source=sidname;User id=userid;Password=pwd" and get TNS Listener errors.
Should I be using something more like "Data Source=serverip,sidname;User id=userid;Password=pwd"? Any help would be appreciated.
Steve
|
|
|
|
|
Hello yall!!
Can anyone tell me why this API call works in vb 6.0 but not in vb .net
this is the functions:
Private Declare Function GetDeviceGammaRamp Lib "gdi32" (ByVal hdc As Long, lpv As Integer) As Boolean
Private Declare Function SetDeviceGammaRamp Lib "gdi32" (ByVal hdc As Long, lpv As Integer) As Boolean
this functions returns true if scucessful and false if not
in vb 6.0 it returns true but in vb .net it returns false
by the way the functions is used to set and get the screen gamma/brightness
SuperDude84
|
|
|
|
|
You might want to post the code your used in VB.NET, so we can see what your doing...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i give you the code:
Private Declare Function GetDeviceGammaRamp Lib "gdi32" (ByVal hdc As Long, lpv As Integer) As Boolean
Private Declare Function SetDeviceGammaRamp Lib "gdi32" (ByVal hdc As Long, lpv As Integer) As Boolean
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Integer, Source As Long, ByVal Length As Long)
Dim SavedRamp(255, 2) As Integer
public REG_KEY as string = ""
Private Function CheckReg() As Boolean
If REG_KEY = "password" Then
CheckReg = True
Else
CheckReg = False
End If
End Function
Private Function Lng2Int(Value As Long) As Integer
CopyMemory Lng2Int, Value, 2
End Function
Public Function GetGamma() As Double
If CheckReg = False Then Exit Function
If GetDeviceGammaRamp(GetDC(0), SavedRamp(0, 0)) = False Then Exit Function
Dim rgb(2) As Double
Dim I As Integer
Dim J As Integer
On Error Resume Next
rgb(0) = 1.01
rgb(1) = 1.01
rgb(2) = 1.01
For I = 0 To 2
Dim Csum As Double
Dim Ccount As Integer
Csum = 0
Ccount = 0
For J = 0 To 255
If J <> 0 And SavedRamp(J, I) <> 0 And SavedRamp(J, I) <> 65536 Then
Dim A As Double
Dim B As Double
Dim C As Double
B = (J Mod 256) / 256.01
A = SavedRamp(J, I) / 65536.01
C = Log(A) / Log(B)
Csum = Csum + C
Ccount = Ccount + 1
End If
Next J
rgb(I) = Csum / Ccount
Next I
GetGamma = rgb(0)
End Function
'Gamma is between 0 and 2
Public Function SetGamma(Gamma As Double) As Boolean
If CheckReg = False Then Exit Function
Dim Ramp(255, 2) As Integer
Dim nVal As Integer
Dim I As Integer
For I = 0 To 255
nVal = Lng2Int((((I + 1) / 256.01) ^ Gamma) * 65535 + 0.5)
Ramp(I, 0) = nVal
Ramp(I, 1) = nVal
Ramp(I, 2) = nVal
Next I
SetGamma = SetDeviceGammaRamp(GetDC(0), Ramp(0, 0))
End Function
Try this out in vb 6.0 and vb.net
|
|
|
|
|
An integer in .NET is 32 bits
If you want to get a 16 bit number use Int16...
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|