|
The CallByName function would do this. But I have to ask why you would want to go through such a hassle? There is no type checking of data being passed to the function or for the type of call your making. On top of that, using this function does not support return values from functions using ByRef passing and there is also a performance penalty.
RageInTheMachine9532
|
|
|
|
|
I'm in research mode and am not yet sure if I do want to go through the hassle. However, I'm trying to develop a class that is flexible enough to read different "lookup" tables from a database into a "collection" (I don't necessarily mean the Collection class). Normally, I would structure the lookup tables so that one set of code would read them all. But in this instance I don't have that luxury. Thanks for your help.
|
|
|
|
|
I created the class called myClass as following in vb.net
<br />
public Class myClass <br />
Public Function add(num1 As Integer, num2 As Integer)<br />
Dim result As Integer<br />
result = (num1+num2)<br />
set add=result<br />
End Function<br />
<br />
End class<br />
<br />
I saved it as myClass.vb
And I go back to the form1.vb
<br />
Public Class Form1<br />
Inherits System.Windows.Forms.Form<br />
<br />
#Region " Windows Form Designer generated code "<br />
Dim pf As New myClass<br />
pf.PrintWord("c:\pckm\101.doc/name_/format_autodate/autodate_/end_")<br />
End Class<br />
<br />
but I have error C:\DotNetProgs\myProg\myProg\Form1.vb(60) : error BC30188: Declaration expected.
|
|
|
|
|
First, your myClass doesn't have a PrintWord method, unless there is extra code in there your not showing us. Also, from the code you have shown us, myClass is a keyword and can't be used as the name of a class. Plus, your class can be greatly simplified like this:
Public Class testClass
Public Function add(ByVal num1 As Integer, ByVal num2 As Integer) As Integer
Return num1 + num2
End Function
End Class
Second, we need to see line 60 of Form1.vb and the code surrounding it to be able to tell you what is going on.
RageInTheMachine9532
|
|
|
|
|
OK. I am confused. I thought deployment was suppose to be easier.
I have a VB.NET app that uses 3rd party DLL's to display a map on the UI and create routes for fleet tracking.
The data is loaded from a web service that uses SOAP to return XML data points that are used to map the routes.
I am getting DLL registration errors on the client's PC when they try to install the app. I used the VS.NET template to create the msi.
What gives???
I should add that the target system had the SOAP SDK and the .NET framework installed on it prior to the app being installed.
Any ideas why the install is getting errors? I thought .NET was not suppose to register DLL's.
|
|
|
|
|
What registration errors for what .DLL's?
Compared to the Package and Deployment Wizard in VB6, the new Deployment Projects are easier and FAR more flexible. Since your using 3rd party DLL's, you still have to make sure that those DLL's get into the .MSI and are registered properly, if needed. The new Deployment Projects DO make deployment easier, but it can't follow the dependancy trail of every single DLL, that MIGHT be called by your app.
RageInTheMachine9532
|
|
|
|
|
They are getting errors on MSSOAP30.DLL and MSXML4.DLL.
The errors say "COM Object with CLSID = "...."... unable to register.
When the client tries to register the DLL's manually (those that were copied during the install into the app's subdirectory) the REGSVR32 reports a "no entry point" error.
I am assuming that the DLL's do "get into the .MSI" because they are copied to the target machine during the install.
What am I missing?
|
|
|
|
|
Hey fellow coders.
I'm writing a program in VB that is designed to take the question and answer file for IRC trivia bots and convert the file format over to be used with another type of trivia bot. As an example of what I need to do here is an example of text I need to parse
I need to convert the line below:
What band got their name from the sixties movie Barbarella?*Duran Duran
To this line:
Duran Duran|What band got their name from the sixties movie Barbarella?
Now, this program opens a text file and copies the entire file to one string variable. That code looks like this:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim currsep As String, newsep As String, lineoftext As String, filetext As String
Private Sub mnu_file_open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_file_open.Click
OpenFileDialog.Filter = "Text Files (*.txt)|*.txt"
OpenFileDialog.ShowDialog()
If OpenFileDialog.FileName <> "" Then
FileOpen(1, OpenFileDialog.FileName, OpenMode.Input)
Do Until EOF(1) 'read file into RAM
lineoftext = LineInput(1)
filetext = filetext & lineoftext & vbCrLf
Loop
lbl_open.Text = "File is open and ready to be converted"
FileClose(1)
End If
End Sub
Private Sub cmd_conv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_conv.Click
'this procedure takes the file (in variable filetext) and performs the parsing.
End Sub
End Class
any ideas for cmd_conv_click?
|
|
|
|
|
Don't read the entire file into a string variable. That isn't necessary at all an makes you job that much harder. What you do is open 2 files. 1 is the file you want to convert, 2 is the file you want to convert to. You do the same thing you did in your sample code with the LineInput but you look for the '*' character and split the string into two strings. Then recombine the strings into the new format and write that into the second file.
Private Sub Convert()
Dim SourceString As String
Dim TargetString As String
Dim Parsed() As String
FileOpen(1, "C:\Source.txt", OpenMode.Input)
FileOpen(2, "C:\Target.txt", OpenMode.Output)
Do Until EOF(1)
SourceString = LineInput(1)
Parsed = SourceString.Split("*")
TargetString = Parsed(1) & "|" & Parsed(0)
PrintLine(2, TargetString)
Loop
FileClose(1, 2)
End Sub
RageInTheMachine9532
|
|
|
|
|
That code works.....for the most part. The problem is if the question/answer set is not all on one line it will crash with a "Index was outside the bounds of the array". error. one condition that will cause this is having a question/answer run over onto another line. Here's the current code:
Private Sub mnu_file_convert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_file_convert.Click
currsep = txt_current.Text
newsep = txt_desired.Text
OpenFileDialog.Filter = "Text Files (*.txt)|*.txt"
SaveFileDialog.Filter = "Text Files (*.txt)|*.txt"
OpenFileDialog.ShowDialog()
SaveFileDialog.ShowDialog()
If OpenFileDialog.FileName <> "" And SaveFileDialog.FileName <> "" Then
FileOpen(1, OpenFileDialog.FileName, OpenMode.Input)
FileOpen(2, SaveFileDialog.FileName, OpenMode.Output)
'Stop
Do Until EOF(1)
SourceString = LineInput(1)
Parsed = SourceString.Split(currsep)
If lst_current.SelectedIndex = 1 And lst_desired.SelectedIndex = 0 Then
TargetString = Parsed(1) & newsep & Parsed(0)
PrintLine(2, TargetString)
Else
TargetString = Parsed(0) & newsep & Parsed(1)
PrintLine(2, TargetString)
End If
Loop
End If
End Sub
End Class
|
|
|
|
|
OK. Then when you parse the string (TargetString=...). Check to see if the array that is returned has 2 elements in it. If not, then you have to go back and read the next line and append it to the one you already have, then parse it again and it should work. Thing is, this will only work if you have 1 question and 1 answer per line or two. If the second line contains the rest of a question, then and answer, then starts another question, you'll run into problems. I know '*' comes between a question and its answer, but is there a second seperator that appears between answer followed by a question?
RageInTheMachine9532
|
|
|
|
|
Hi,
I need speech to text examples.pls help me.
|
|
|
|
|
Could you be a little more specific? What library/controls/API package(s) are you using to do the speech recognition?
Microsoft has at least 3 packages that I know of, then there are third party packages...
RageInTheMachine9532
|
|
|
|
|
hi,
I am using Sapi.could u give some guidence.
|
|
|
|
|
Well, SAPI 5.2 is the foundation of the Speech Application SDK, but version one of this SDK is at Beta 3 right now. You can try it out by following the Getting Started for First-Time Users here[^]. There is also a pretty decent tutorial on it here[^].
I haven't used it myself, but I tried out the tutorial with no real problems.
RageInTheMachine9532
|
|
|
|
|
I have a program that needs to have focus all the time but have no idea where to start.
The program is set to form on top but I do not want it to lose focus. Please help!!
|
|
|
|
|
First, your Application never really has the focus. It's title bar changes color because one of it's child controls has the focus. A form is nothing but a control, but a control that can contain other controls.
Individual controls get and lose focus. Its a pain to manage if your trying to retain the input focus to just your app (form). You have to keep track of which control actually has the focus and if none of your child controls has the focus anymore, which control do you give it back to?
A better way would be to redo the form(s) your using and show them as system modal dialog boxes. This way, Windows manages the focus for you and you can't leave the app until the dialog box goes away. Search the documentation for ShowDialog to see what I mean.
Your app needs to have the focus all the time? Why? It kind of make using the rest of the system a pain to use if you can't so much as click on the "Start" button...
RageInTheMachine9532
|
|
|
|
|
I need to validate a password field with RegularExpression Validator. The validation logic is bit complex for me. Can anyone help me out with this
Password must be a minimum of 8 characters and contain a combination of 3 of the following characters:
- numbers
- upper case letters
- lower case letters
- special character (*%$)
I need this urgently. PLEASE SOMEONE PLS HELP.
THANKS in advance
|
|
|
|
|
A regular expression to do this (mostly because of the 3 out of 4 clause, would be incredibly long and would require intensive CPU time and quite a bit of memory. I would recommend that you instead create a custom validator that enumerates the characters and keeps a count, something like this:
' Assume password is in a string variable called "password"
If password.Length < 8 Then Return False
Dim i As Integer = 0
Dim b1 As Boolean
Dim b2 As Boolean
Dim b3 As Boolean
Dim b4 As Boolean
For Each c As Char In password
If Char.IsLetter(c) Then
If Char.IsLower(c) And Not b1 Then
b1 = True
i++
Else If Not b2
b2 = True
i++
End If
Else If Char.IsNumber(c) And Not b3 Then
b3 = True
i++
Else If (c = "*"c Or c = "%"c Or c = "$"c) And Not b4 Then
b4 = True
i++
End If
Next
If i >= 3 Then Return True
Else Return False
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Dear All,
I used OLe Container in VB6.0 to upload image to database.
The image is saved in database as compounded file binary.
Now I am using VB.NET to retrieve the file.. but somehow I could not extract the
embedded file from that OLE Binary.
Does someone have a workaround for this?
Much Appreciated.
Sandy
|
|
|
|
|
This should work for you. I know that it works with MS-Access. Assuming you table contains the following fields
IMAGE_ITEM_ID : Long
NAME : Text
IMAGE : OLE Object
Public Sub GetItem(ByVal itemId As Long)
Dim sqlQuery As String ' the query to execute
Dim image() As Byte ' the image to get
Dim name as String ' the name of the image
sqlQuery = "SELECT IMAGE_ITEM_ID, NAME, IMAGE " & _
"FROM IMAGE_ITEM " &_
"WHERE IMAGE_ITEM_ID = " & itemId
Try
' instanciate a connection object
Dim conn As OleDb.OleDbConnection = GetConnection()
' instanciate a command object
Dim com As New OleDbCommand(sqlQuery, conn)
' open the connection
com.Connection.Open()
' create a read to read the database
Dim reader As OleDbDataReader
' open the reader
reader = com.ExecuteReader(CommandBehavior.CloseConnection)
' read the first record
If (reader.Read()) Then
' get the name of the image
name = reader.GetString(1)
' get the image
itemData.Image = CType(reader.Item(2), Byte())
End If
' clean up after yourself
reader.Close()
com.Connection.Close()
conn.Dispose() 'release memory to garbage collection
com.Dispose() 'release memory to garbage collection
Catch eOleDb As OleDb.OleDbException
MsgBox("OleDb Error - GetItem - [" & eOleDb.Message & "]")
End Try
End Sub
I hope it works for you.
|
|
|
|
|
What is the best practice for generating a standard report in a VB.NET app?
I have tabbed form a user fills out then clicks file, print to print the record just created. Printing the data entry screen is not an option. For instance you fill out a customer order then you want to print the order. Do you create another windows form or is there a special type of form for printing?
I know this is a newbie question but I am just looking for some general guidance not a step by step walk through.
Thanks,
Sean
|
|
|
|
|
Hi Sean. You could use a dedicated report control, like Crystal Reports for this. You could also investigate the PrintDocument class - to print a customer order, you could either sub-class PrintDocument or add your own event handler to respond to the PrintDocument's PrintPage event. The .NET SDK documentation has some examples.
|
|
|
|
|
hello to all
i am using this code to send a message from my system (sys 1) to the other system (sys 2).
its working fine..... for this i need to use APIs. but i want to send a message using the shell command. can any body give the exact syntax for it ?.
next one ... is there any way to know in/from the sencond system (sys 2) ( ... to which i am sending the message ) that it has got the message when ever i send a message to sys 2 ?.
so that i can show a popup (just like msn messenger do) or play some sound when ever sys 2 gets a message from sys 1.
here is the code ...
Private Declare Function NetMessageBufferSend Lib "NETAPI32.DLL" (yServer As Any, yToName As Byte, yFromName As Any, yMsg As Byte, ByVal lSize As Long) As Long
Private Const NERR_Success As Long = 0&
Public Function BroadcastMessage(sToUser As String, sFromUser As String, sMessage As String) As Boolean
Dim yToName() As Byte
Dim yFromName() As Byte
Dim yMsg() As Byte
Dim l As Long
yToName = sToUser & vbNullChar
yFromName = sFromUser & vbNullChar
yMsg = sMessage & vbNullChar
If NetMessageBufferSend(ByVal 0&, yToName(0), ByVal 0&, _
yMsg(0), UBound(yMsg)) = NERR_Success Then
BroadcastMessage = True
End If
End Function
Private Sub Command1_Click()
Dim x As Boolean
x = BroadcastMessage(TxtTo.Text, TxtFrom.Text, TxtMsg.Text)
If x Then
MsgBox "Message Sent"
Else
MsgBox "Message Not Sent"
End If
End Sub
any body please help me
Mohan G
|
|
|
|
|
hi there, basically i am new to VB.net and need a bit of help
i have a string like "Track 01 (2.33)". this string is an item of of a combo box
what i need to do is by clicking a button separating "Track 01" and put it in a list box and "2.33" in another list box...
can you help me plaese?
|
|
|
|