|
hi there,
when is suitable using a dictionary instead of an arraylist and wayback?
i mean, i can't retrieve an object from an arraylist using a string key, is it?
there are other difference/condition? i.e. array dimension or whatever?
thanks in advance!
fuel2run
|
|
|
|
|
If you want to use a String type key to retrieve data then you have to use a class that implements IDictionary , like a HashTable or SortedList . There are other classes, but those seem like they'll fit your needs. Anything that implements IDictionary is accessed by a key/value pair. You give it the key as a kind of index and the IDictionary will return the value associated with it.
ArrayList 's are accessed by an Index value, usually an Integer type.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
I want to send a message to another computer by writing VB!!! Who can help me???
Thanks
tramdtt
|
|
|
|
|
There are a number of ways to send "messages" to other computers. Could you be more explicit in your request. Is the message aimed at a user, an existing process/application, another application you are writing, etc.?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Hi, Colin Angus Mackay
Thank for your answer. But can u say more clearly? I am writing a program which send and receive files using Winsock. But i want to send a message to received computer to notice whenever a file is sent to.
Which functions can I use to send message to received computer? I write in VB6,0.
Help me
Thank
tramdtt
|
|
|
|
|
Just use a socket and sent it a simple string saying it's done. There's exhaustive information about writing sockets on the net and in the MSDN.
|
|
|
|
|
When you send the message, is there going to be a client app on the detination computer that will recieve this message? If not, you'll need one!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I use Winsock to write a app send and receive files throughout computers on LAN. I used to use SendData method to send a string to app of destination computer . But I want to send a message to notice to destination computer whenever files are delivered to destination computer.
Which functions Can I use in this situation?
Help me!
Thanks
tramdtt
|
|
|
|
|
I have a global system hook, using "dscwpmsg.dll" and an example from www.allapi.net (acording to the read me: a system wide Hook of the types "WH_CALLWNDPROC" and/or "WH_GETMESSAGE").
I want to know when the a user RIGHT clicks on the minimize (or any other) button of the control box (top right of every window).
If any one has any ideas I'd appriciate it. And before any one sais you can't (people on IRC caim it is not possible): it is possible, I have an application that does it, now I want to know how...
|
|
|
|
|
Hello..I'm new in VB.net
I have form with display button and text box.
I have myclass.
<br />
Namespace theClass<br />
<br />
<br />
' The class is named StringProcessor.<br />
Public Class myClass<br />
<br />
Public Sub printOut(ByVal t as String)<br />
<br />
MsgBox(t)<br />
End Sub<br />
End Class<br />
End Namespace<br />
Then I want to print out what the use type in so I call
printOut(Me.InputText.Text)
but I got error message like
An unhandled exception of type 'System.NullReferenceException' occurred in BrianHuang_Unit5.exe
Additional information: Object reference not set to an instance of an object.
help me how to correct it please.
|
|
|
|
|
You don't give the stack trace of the error message, so it is harder to tell WHERE it happened.
Given the code snippet you've supplied Me.InputText is the most likely culprit, if so that means you have not set it to an instance of an object. You need to instantiate Me.InputText first.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
We need to know on what line the exception occured, otherwise we really can't tell you with any accuracy what you did wrong.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
This is in form.
<br />
Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click<br />
Dim sp As Course.theClass.myApp<br />
sp.printOut(Me.InputText.Text()) ' here the error pointing to.<br />
End Sub<br />
the myApp class
<br />
Option Strict On<br />
Option Explicit On <br />
<br />
Imports System.Windows.Forms<br />
<br />
' The class module is enclose in a namespace named CountingStatement. <br />
' The root namespace was set to Course using the Project Properties dialog box. <br />
Namespace theClass<br />
<br />
' The class is named StringProcessor.<br />
Public Class myApp<br />
Public Sub printOut(ByVal theText As String)<br />
'get the total number of characters,#of Words, #of paragraph, and # of sentence in that paragraph. <br />
MsgBox (theText)<br />
End Sub<br />
End Class<br />
End Namespace<br />
It is not as easy as c++. I dont know how to call the class function from the other class in VB.net.
Thank you
|
|
|
|
|
The problem is that you delcared sp as Course.theClass.myApp, but you never instantiated it. It should be:
Dim sp As New Course.theClass.MyApp
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thank you... it works now.
|
|
|
|
|
does anyone know somewhere when they have written code to verify what users are signed onto a program.
for example. If i only want 10 users logged in at once but 100 possible users in the program. Each instance will be running on a diff pc and i cant figure out how to validate what users are logged on and limit the logged on users to 10
Vince
|
|
|
|
|
Your application would need its own licensing server. Something you would have to write from scratch and into your application. Your app would ask the user for an username and password, login into the license server, check out a license on a lease (timed) basis, say 30 minutes, and when the app quits, check with the license server to return the license. You would also have to write into the license server some kind of timeout where if the server did not hear from the client, the license would be returned to the license pool. The clients would also have to check in with the server occasionally to renew their leases. This is necessary for the simple reason an application could hang and the license would be checked out without ever being checked back in properly. Not too hard to write, but, like I said, you'd have to write it from scratch.
Oh! Then you would need a management tool to administer the license server too...
Or buy the components from a 3rd party, of which I have no idea who sells something like this...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ok, Building a game for my school final project and I have enought programming skill to know loops, if's, and a bit of other things.
I was wondering what is the way a person with my programming abilities would go about adding sound and playing it within VB. It would be appreciated if soeone could help me out. Otherwise I have a soundless, boring game.
|
|
|
|
|
Well, the simple way to do it is buy calling into the Win32 API. Something, I take it, your class never covered...
But, anyway, you would Declare the call into the API like this:
Private Declare Function Beep Lib "kernel32" Alias "Beep" _
(ByVal dwFrequency As Long, ByVal dwDuration As Long) As Long
Then, when you want to play a sound:
Beep 5000, 250
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks alot Dave, now I will have the rockinest game ever!
That is very, Very, VERY, VERY!, cool. Thanks alot..again.
(amended after school)
Ok uh..instead of the beeps...because my computer teacher hates me now because the room was full of...beeping, how would I play a .wav, like "sound.wav" within VB? Then with actual sound it would benifit me very much.
|
|
|
|
|
how can i delete this chater "
from a string, like this one
"c:\windows
<br />
'sample code<br />
<br />
cmdline$ = "c:\windows\notepad.exe" <br />
path = cmdline$<br />
WorkingDirectory = Mid(path, 1, InStrRev(path, "\") - 1)<br />
MsgBox WorkingDirectory<br />
jeroen
|
|
|
|
|
Replace(Command$, Chr$(34), "")
Chr$(34) could be "\"" i could be wrong.
Shin
|
|
|
|
|
You might want to check into using the Path class to return full paths to files and directories:
cmdLine$ = chr$(34) & "C:\Windows\notepad.exe" & chr$(34) ' "C:\Windows\notepad.exe"
WorkingDirectory = Path.GetFullPath(cmdLine$) ' will be C:\Windows\notepad.exe
WorkingDriectory = Path.GetPathRoot(WorkingDirectory) ' Should be C:\Windows
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Going to use it for CreateProcessA
<br />
Public Function ExecuteAndWait(cmdline$)<br />
On Error GoTo Error<br />
<br />
Dim NameOfProc As PROCESS_INFORMATION<br />
Dim NameStart As STARTUPINFO<br />
Dim x As Long<br />
Dim WorkingDirectory As String<br />
Dim Path As String<br />
<br />
Path = cmdline$<br />
WorkingDirectory = Mid(Path, 1, InStrRev(Path, "\") - 1)<br />
<br />
MsgBox WorkingDirectory<br />
GoTo Quit<br />
NameStart.cb = Len(NameStart)<br />
x = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, WorkingDirectory, NameStart, NameOfProc)<br />
x = WaitForSingleObject(NameOfProc.hProcess, INFINITE)<br />
x = CloseHandle(NameOfProc.hProcess)<br />
<br />
Exit Function<br />
Error: ' Error handling<br />
MsgBox "Run-Time Error number " & Err.Number & vbCrLf & Err.Description, vbOKOnly + vbCritical, "CreateProcess"<br />
GoTo Quit<br />
Quit:<br />
End Function<br />
i cant find declare sampels with api text viewer
<br />
GetFullPath declared like this : ?<br />
<br />
Public Declare Function GetFullPath Lib "kernel32" Alias "GetFullPathNameA" (ByVal lpFileName As String, ByVal nBufferLength As Long, ByVal lpBuffer As String, ByVal lpFilePart As String) As Long<br />
<br />
<br />
GetPathRoot declared like this : ?<br />
<br />
Private Declare Function GetPathRoot Lib "gdi32.dll" (ByVal hdc As Long, ByRef lpPoint As POINTAPI, ByRef lpTypes As Byte, ByVal nSize As Long) As Long<br />
<br />
<br />
thanks for helping
jeroen
|
|
|
|