|
I don't think you can. I would imagine the function would be something like this in C# - or you can modify this to work as required:
public static byte CByte(object expression)
{
byte result = 0;
if (expression is IConvertible)
{
try
{
result = Convert.ToByte(expression);
}
catch
{
}
}
return result;
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
What's wrong with using Convert.ToByte()???
No jumping through hoops, no VisualBasic namespace, just a conversion...
|
|
|
|
|
This is the best solution.
Note that "CByte" and the other related ones (CInt, CStr, etc.) are operators in VB and are not methods in any library, so you have to use something else, such as Convert.ToByte as recommended by Dave K.
David Anton
http://www.tangiblesoftwaresolutions.com
Convert VB to C#, C++, or Java
Convert C# to VB, C++, or Java
Convert C++ to C#, VB, or Java
Convert Java to C#, C++, or VB
|
|
|
|
|
Hi
Is there any way of capturing a link click event from a DataGridViewLinkCell?
I'm starting to think that this column's only purpose is to underline text...
Anyway, any help is apreciated
Thanks
|
|
|
|
|
Take a look at this answer to a similar problem[^], substitute LinkLabel for CheckBox and use the event of your choice.
I have never used a LinkLabel , so cannot help on that part of it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
im programming a tournament draw system in vb .net, which is an elimination system. i have completed all other modules in this project, now i need to make the draw. As there is an underlying points system, i need to record the byes, which do not score, and wins, which score 1 point.
so, if there are 5 entrants [a,b,c,d,e] in a particular division, the first round would be:
[a,b]
[c,d]
e
where b and c win, and e receives a bye. the second round would be:
b
[c,e]
where b now receives the bye. after this there would be 1 more round; a total of 3 rounds, 2 byes and 4 matches
how can i do this programmatically? i cant find a suitable pattern to follow or any useful info on google
has anyone made something similar? is there some keyword that i should search for?
i do realise that i havent supplied any actual code, but i dont have any to attach that would prove relevant
thanks,
-n
|
|
|
|
|
Your question interested me, so I did a bit of searching. It is incredibly difficult to find a search term that gives any meaningful results, however I did find this[^].
I hope it is of some help.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks for the link,
"Bayesian locally optimal design of knockout tournaments" is what i got from that article. After a bit of searching i found a report which mentioned phantom players, just adding these to fill a division up to a power of 2
thanks again
-N
|
|
|
|
|
Hi,
I have created a form which I need to draw a triangle in it.
I found a block of code in internet like this:
Dim Graph As Graphics
Dim Ps() As Point
Graph = Graphics.FromHwnd(hwnd:=ActiveForm().Handle)
ReDim Ps(2)
Ps(0) = New Point(150, 25)
Ps(1) = New Point(150, 125)
Ps(2) = New Point(350, 125)
Graph.DrawPolygon(pen:=New Pen(Color.Black, Width:=1), points:=Ps)
it is in paint event of form,
it works when I load it by itself, but when I try to load it in a mdiParent form
the triangle doesn't show up,
can any one help me?
also I'm new to vb.net so if there is a better way to draw things please tell me
Thanks in advance
|
|
|
|
|
Actually I changed
Graph = Graphics.FromHwnd(hwnd:=ActiveForm().Handle)
to
Graph = Graphics.FromHwnd(hwnd:=Me.Handle)
and it works
I just need to know what ' := ' does
like
Width := 1
|
|
|
|
|
":=" sets parameters being passed to a method by name instead of relying on the order of parameters.
You REALLY should be doing your form painting in its Paint event instead of creating your own Graphics object.
|
|
|
|
|
assuming arrival method is still executing after say 40s seconds . how can i prevent the service from calling another instance pf arrival method
Public Class intestService
Protected Overrides Sub OnStart(ByVal args() As String)
Dim tDelegate As Threading.TimerCallback = AddressOf Arrival
oTimer = New System.Threading.Timer(tDelegate, Me, 10, 40)
End Sub
Public Sub Arrival(ByVal sender As Object)
'File.AppendAllText("C:\test4.txt", "AuthorLogService fires arrival at " & Now.ToString())
Try
'
Catch ex As Exception
log.WriteEntry(ex.Message, EventLogEntryType.Error)
End Try
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
End Sub
End Class
|
|
|
|
|
Dim TimerThreadIsRunning As Boolean Set it to true when you start your thread, and back to false at the end of Arrival method. Start the thread only if the boolean is false.
My advice is free, and you may get what you paid for.
|
|
|
|
|
hi
currently i'm facing a problem in creating a graph as well as pie chart using VBA. could any kind soul please help mi with it
Thanks
Warm Regards
Veon
|
|
|
|
|
VBA stands for Visual Basic for Applications. So, which "application" are your writing this code in??
|
|
|
|
|
Hi all
I am trying to create a small program in VB.Net (VS2005) that acts like a realtime application program like any antivirus program.
I want to know that how realtime program works?? How an antivirus program reports when a virus found??
I want to create a program that will report user when a usb device attached.
How can I do this? Should I create a Windows service or anything else??
Suggest me how can I do this.
Thanks.
Gagan
|
|
|
|
|
A "realtime" application works by sitting there waiting for a message to show up in it's message pump, or waiting for a timer tick to tell it to poll for some data, or registering for a notification message, or whatever...
A service might work, but they are not supposed to be showing a user inteface. You're best bet would be to write a normal application that gets launched when the user logs in and just puts a NotifyIcon in the tray. You'd probably want to create a hidden window and override it's WndProc, looking for the WM_DEVICECHANGE message.
|
|
|
|
|
Hi, Does anyone know how to detect whether a key on the keyboard is being pressed outside of your application? This code seems to work for detecting the keypress as long as your focus is on the form. I think it has to do with the handles myBase.keypress. Am i correct that mybase.keypress is looking for a key being pressed inside the form? Is there something else that i could write such as system.keypress or something that could detect any time the key is pressed?
Public Sub Form1_KeyPress(ByVal sender As Object, ByVal ex As KeyPressEventArgs) Handles MyBase.KeyPress
If keypush = False Then
keypush = True
End If
End Sub
I really appreciate it.
Thanks a lot.
|
|
|
|
|
RyJaBy wrote: This code seems to work for detecting the keypress as long as your focus is on the form. I think it has to do with the handles myBase.keypress. Am i correct that mybase.keypress is looking for a key being pressed inside the form?
Yes, that's right. The form key events will only fire if the form has the input focus.
RyJaBy wrote: Is there something else that i could write such as system.keypress or something that could detect any time the key is pressed?
No, there's no such event. You'd have to use a far more advanced technique called a "global keyboard hook". Just Google for that phrase, and maybe add "VB.NET" to the end, and you'll come up with loads of examples.
|
|
|
|
|
Do you know the difference between vb.net and just vb? is there a difference? Thanks again for the help I really appreciate how quickly you respond.
|
|
|
|
|
vb (I assume you mean vb6 with that) is outdated / unsupported / and is/never was any good.
vb.net is the new version and uses the .NET framework.
(that's it in a nutshell)
|
|
|
|
|
The old VB doesn't have taht ability either. You still have to use a global keyboard hook.
|
|
|
|
|
The Managed Windows API has some really easy functions for Global Keyboard Hooks.
http://mwinapi.sourceforge.net/[^]
Have you tried the Krypton Toolkit? http://www.componentfactory.com/free-windows-forms-controls.php
|
|
|
|
|
I've been using Cursor.Current to get the mouse point image but it doesn't capture alpha correctly. Is there something I can do to make it give me the alpha correctly?
Have you tried the Krypton Toolkit? http://www.componentfactory.com/free-windows-forms-controls.php
|
|
|
|
|
I can't remember exactly, but I think the Cursor class didn't work with 32-bit cursor images with alpha. I believe this had to do with a problem in GDI+, but I could be wrong.
I think you'll have to use Win32 API functions directly to get at the complete image, though I don't know exactly how to do it. I'd probably start by looking into the GetCursor and CopyImage Win32 functions.
|
|
|
|