|
Ok, let me attempt this blindly since I do not have all the code LOL! Lets start with the First one. I may rename variables but you'll get the idea.
The number one thing in dealing with API Calls is this:
Imports System.Runtime.InteropServices 'Put in Header
'=====================
'1.)
Public Function MoveNext() As Boolean
Dim svrInfo As Win32API.SERVER_INFO_101
Dim bResult as Boolean = False 'Unnecessary because Boolean = False by default
CurrentItem += 1 'Increment the CurrentItem Counter
If (CurrentItem < ItemCount) Then
Dim iOffset As Integer = (svrInfoPtr.ToInt32 + SERVER_INFO_101_SIZE * CurrentItem)
Marshal.PtrToStructure(New IntPtr(iOffset), GetType(svrInfo))
CurrentServerName = Marshal.PtrToStringAuto(svrInfo.lpszServerName)
bResult = True
End If
Return bResult
End Function
'=====================
Lets make it a little better by using some Error Trapping. Try this next example:
'=====================
'1.)
Public Function MoveNext() As Boolean
Dim svrInfo As Win32API.SERVER_INFO_101
Dim bSuccess As Boolean
CurrentItem += 1 'Increment the CurrentItem Counter
If (CurrentItem >= ItemCount) Then Return False 'Exit if the Item is outside the Memory Address Range
Try
Dim iOffset As Integer = (svrInfoPtr.ToInt32 + SERVER_INFO_101_SIZE * CurrentItem)
Marshal.PtrToStructure(New IntPtr(iOffset), GetType(svrInfo))
CurrentServerName = Marshal.PtrToStringAuto(svrInfo.lpszServerName)
bSuccess = True
Catch
'Display Error Message if you want
bSuccess = False
End Try
Return bSuccess
End Function
'=====================
To be continued...
Not all those who are lost are looking to be found. But of those who are lost and those who are found, all are looking for something higher than themselves.
|
|
|
|
|
...Continuation:
'=====================
'2)
Public Function GetServerType(ByVal ServerName As String) As ServerTypes
Dim svrInfoPtr As IntPtr = IntPtr.Zero
Dim svrInfo As Win32.SERVER_INFO_101
Dim hResult As Integer = Win32API.NetServerGetInfo(ServerName, 101, svrInfoPtr) 'Make sure the API Declarations have the Appropriate Byval / Byref
If (hResult <> 0) Then
'Marshal.PtrToStructure(svrInfoPtr, GetType(svrInfo))
Marshal.PtrToStructure(svrInfoPtr, svrInfo)
Return Ctype(svrInfo.dwType, ServerTypes)
Else
Return ServerTypes.None
End If
End Function
I am sorry if there is anything wrong with these Posts...again, I did this all by looking at it and I did not "Pre-Code" this to see if it works.
Good luck!
Not all those who are lost are looking to be found. But of those who are lost and those who are found, all are looking for something higher than themselves.
|
|
|
|
|
I am using VB.Net..
I have been trying this for awhile...
Im making a simple console app that is a database for different video games.
It will store the name, genre and a rating out of 10..
But I want it set up as several sub procedures to clean up my code.
Also because I hoped it would look like an old DOS menu based system...
Something like this:
Games Database
--------------
1) Add a game
2) Display a games info
3) Display rating average
4) Display rating summary
5) Delete a game
6) Quit
Enter a choice:_
______________________________________________
"I'm not me when I dream...anymore." -TRUSTcompany
|
|
|
|
|
This is what i have so far..and i'm getting an error...
Module Exercise4
Private Structure Game
Dim name, genre As String
Dim rating As Single
End Structure
Sub Main()
Dim gameArray() As Game
Dim choice, count As Integer
Dim name, genre As String
Dim rating As Single
Call DisplayMainMenu()
choice = CInt(Console.ReadLine())
If choice = 1 Then
Console.Write("Enter the name of the game: ")
gameArray(0).name = CStr(Console.ReadLine())
End If
Console.ReadLine()
End Sub
Private Sub DisplayMainMenu()
Console.WriteLine(" Game Database" & vbCrLf & " -------------")
Console.WriteLine(vbCrLf & "1) Add a Game" & vbCrLf & "2) Display a Game")
Console.WriteLine("3) Display Rating Average" & vbCrLf & "4) Display Rating Summary")
Console.WriteLine("5) Quit" & vbCrLf)
Console.Write("Enter a choice: ")
End Sub
End Module
______________________________________________
"I'm not me when I dream...anymore." -TRUSTcompany
|
|
|
|
|
What's the error and where does it point to?
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
I figured it out, but thanks anyway
______________________________________________
"I'm not me when I dream...anymore." -TRUSTcompany
|
|
|
|
|
can anyone help.
I want to record audio from a mic to a wav file in vb.net.
can anyone show me some sample codes etc..
thanks
Paul
|
|
|
|
|
sir
i have a VC++ com dll that returns an array of strings.
i want to pass the address of this string array to a pointer & pass this pointer as a argument to a function in vb.net / C#
how do i do this
|
|
|
|
|
Wow. I was reading this stuff about how great VB .NET is for Game programmign and it says it supports Multithreading. Hmmm. Someone please tell me what this is?
Thanks
|
|
|
|
|
Haven't you done any courses in Computer Science. I sure threads were one of the subjects covered. Anyways...
An Application that is running is usually refered as a process. Within that process, or any process for that matter, are pieces of related codes, or Threads. Thus, a process is made up of one to many pieces of thread.
Now, in VB6, multithreading is not supported since your code gets executed step by step. A thread will have to wait for another thread to finish before it can execute. This can lead to your resources being wasted. An example of this is a thread that is writing to disk. When this thread is executing, the CPU is idle when it could be doing something.
The concept of multithreading is that the CPU should always be doing something, to fully utilize it. VB.Net allows you to execute more than one thread at the same time, thus fully utilizing your app.
For more imformation, try buying a Comp Sci book. I'm sure their explanation is much, much better.;P
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
Hi all,
I have been roaming aroung with ASP/html/JSCripts for a while in the office. And a sudden boom, 'SPS try something with VB, we need you as a resource there'.
As I know nothing head/tail there, I wanted to try my hand by any 'quick reference' or 'kick start' on VB. VB 6.0, will do for me now, will migrate to .NET, when my company gets that stuff.
Links, tutorials are welcome....
Thanks a lot
I was born intelligent Education ruined me!.
|
|
|
|
|
|
Thanks a lot..... I too tried with google. But wanted a quick answer... so I posted here.
Thanks again
I was born intelligent Education ruined me!.
|
|
|
|
|
you could buy either the complete idoits guide to vb or vb6 for dummies but i recommend the idiots guide they are always better
|
|
|
|
|
My problem seems to be an issue of generating random numbers. While the statements are quite clear and easy and all of us are familiar with it, I never can seem to come up with a set of truly random numbers, while hating to sound totally stupid and an idiot, it has been quite frustrating. I have used the "Randomize" statement, but it seems to not work very well or I have overlooked something that is far too easy. The program I am creating relies on a set of truly randome numbers to function.
I use Visual Basic.net and I also Have Visual C++.Net as well, maybe I should switch gears and use another programming language??
Michael Goesch
|
|
|
|
|
Computers cannot pick truly random numbers.
They can't make guesses...
They don't feel pain, or remorse...
Oh, sorry... getting carried away there.
http://home1.gte.net/deleyd/random/introduction.html[^]
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."
Unknown wrote:
"I love long walks, especialy taken by those that annoy me."
Paraphrased from TMNT:
"Cricket? You have to know what a crumpet is to understand Cricket."
|
|
|
|
|
i had a similar problem with vb.net first i had coded the game yahtzee in vb6 and it worked fine then i was converting it into vb.net and after i got all the stuff out of the way i ran it in debug mode and i saw i got 5 random numbers which i use to change the pictures of the die showing but when i took it out of debug mode i get the same five numbers like i get all 1's or all 2's etc but the moment i put it into step by step debug it works perfectly again so maybe its a bug in .net cause i got pretty pissed off because i thought how in the hell do i debug something that works perfect in debug mode? don't know if this helps or not
|
|
|
|
|
Hi,
I want to copy a Table (in sql server) to a specified Text File programmatically using DTS.Can any one help me?If possible can u please paste the code?
Thanks in advance
|
|
|
|
|
You can do this one of three ways.
1.) The best way is to use an ADO Recordset / ADO.NET DataSet and use the "Save" / "WriteXML" Methods. This is best because both the Recordset and DataSet can open an XML file.
2.) Use BCP to Bulk Export data from the Table to a Text File. This is essentially what the DTS does.
3.) There is also a way to Bulk export using an XML format but I can't remember the command.
Not all those who are lost are looking to be found. But of those who are lost and those who are found, all are looking for something higher than themselves.
|
|
|
|
|
Hi,
I build a .NET COM class that has a method (Print) with some parameters:
.NET Code:
Class Print
Public Function DoPrint( _
ByVal PDFPath As String, _
ByVal PDFName As String, _
ByVal Printer As String, _
ByVal sSQLCol() As String)
VB6 Code:
dim cPrint as New Print.DoPrint
Dim stringSQL1, stringSQL2 as String
Dim SQLArray() As String
stringSQL1= "SELECET * FROM TABLE1"
stringSQL2 = "SELECT * FROM TABLE2"
SQLArray(0) = stringSQL1
SQLArray(1) = stringSQL2
cPrint.Print(pdfpath, pdfname, printer, SQLArray)
When I try to compile the VB6 app it gives me the following error:
"Function or interface marked as restricted, or function uses an Automation type not supported in Visual Basic"
How can I do this?
Many thanks in advanced.
Pedro
|
|
|
|
|
ordepavlis wrote:
Class Print
Public Function DoPrint
....
dim cPrint as New Print.DoPrint
I didn't know you could initialize a variable to a method ( DoPrint is a method). Perhaps that's where the error is??
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
Hi,
Sorry, You are rigth!! I copied the code badly.
So here it is the correct code:
.NET:
dll Name -> Print
Class Name -> CReport
Method -> DoPrint
VB6:
dim cPrint as New Print.CReport
Thanks
Pedro
|
|
|
|
|
ordepavlis wrote:
Dim stringSQL1, stringSQL2 as String
Perhaps it's this part. When do this in vb6, stringSQL1 is dimensioned as a variant datatype. So you're actually passing variant when you're supposed to be passing string.
You should declare it like this
Dim stringSQL1 as string, stringSQL2 as string
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
Hi,
It gives me the same error.
Pedro
|
|
|
|
|
As control array is no more supported in VB.NET ,but i have more than 100 textboxes in my form ,I want to access those with help of index in a loop ,as shown below
for i=0 to n
txtName(i).text=i.tostring
next
How it is possible please help me with source code.
|
|
|
|