|
I have a large function that has a piece of code that gets repeated 8 times or so. Normally I would just make another function and pass all the variables as byref but in the code that repeats I would have to pass EVERY variable in the Larger function 20+ arguments just to get this small one to work. Now yea I can do that but I'm lazy... so here's my question
Is there a way to make an "Inner" function/sub that you can only use inside another specific "Outer" function/sub where you don't have to pass all the variables from the outer to the inner but you can just pass the addressof or something and be able to automatically use all the variables from the outer in the inner.
|
|
|
|
|
It sound like you are looking for object oriented programming.
Create a class with properties for each variable. Instantiate the class in your "outer" sub / function, set the properties, use them, and then when you want to call your other sub / function, you only make a byval of your class, and pass the instantiated object to it.
Something like:
Module ExampleModule
Private Sub ExampleSub()
Dim MyExampleObject As New Example
MyExampleObject.MyVariable = "Example"
'some loop here
MyFunctionToBeCalledAboutEightTimes(MyExampleObject)
'next loop
End Sub
Function MyFunctionToBeCalledAboutEightTimes(ByVal MyExample As Example) As Integer
If MyExample.MyVariable = "Example" Then
Return 0
Else
Return 1
End If
End Function
End Module
Public Class Example
Private _MyVariable As String
Public Property MyVariable() As String
Get
Return _MyVariable
End Get
Set(ByVal value As String)
_MyVariable = value
End Set
End Property
End Class
My advice is free, and you may get what you paid for.
|
|
|
|
|
I am writing a small code in VB.NET
when I try to change the "VALUE" property of a ProgressBar in FOR EACH loop like following example it is not accepting the VALUE as a property of the box! if i try to change something like name or text it is okay! but with VALUE is not working
who can help me please?
For Each Item As Windows.Forms.Control In Panel1.Controls
Item.vlaue = Delay
Next
|
|
|
|
|
Hi,
Controls is a collection holding controls, so your for each variable is and must be a Control.
However a general Control only has a few properties, such as Name and Type, it does not have a Value.
Some more specialized controls do have a Value. So you need to copycast your control reference to a ProgressBar reference for those controls that are ProgressBars.
I can't be more specific, I don't know the details in VB.NET (in C# you would use the "as" keyword and a null test).
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
yesss... thanks for your help
|
|
|
|
|
I can change LINE charts Series with the commands, but not a bar / cylinder chart
Dim series1 As excel.Series = CType(ChartPage.SeriesCollection(1), excel.Series)
series1.MarkerForegroundColorIndex = 3
|
|
|
|
|
How do I get the microsoft word to prompt for password each time a new page is opened. Either this is possible or am beginning to freak myself out on security.
Thanx in advance.
|
|
|
|
|
Asking for a password every time you start a new page in Word?? Are you insane?? Are you trying to make your users of Word insane??
Possible, but easily defeatable. There is no real solution for this since Word doesn't support an extensive security model.
|
|
|
|
|
its just my system, dont share it with anybody.Guess we can do what we like with what is ours.
Thanx any way.
|
|
|
|
|
Guy, there's no real way to do it. Word doesn't support a security model extensive enough to support this in a way that is not easily defeatable.
|
|
|
|
|
Dave, thats ok, Thanx men!
|
|
|
|
|
So you are the one who wants people to hate MS Word and switch to open office.
|
|
|
|
|
I am having difficulty communication through a socket. I am new to this, so bare with me.
I am trying to pass string control protocols to a device like a display sign.
Here is how I have connected to the sign. I think this has worked because I don't get an error. Plus, when I try to connect again it says that I am already connected.
Private endpoint as new IPEndPoint(ipaddress, port)
private socket as new socket(endpoint.addressFamily, SocketType.Stream, ProtocolType.Tcp)
--Sub
socket.connect(endpoint)
--end sub
The issue is when I try to send the protocol text string to the sign. I need help formatting the string.
EXAMPLE: The documentation says to send <0x01>Z00<0x02>AA<0x1C>1<0x1D>B3This is where message is.<0x04>
So I changed it to hex:
dim signmsg = This is where message is.
dim signstring = &H1.tostring + "Z00" + &H2.tostring + "AA" + &H28.tostring + "1" + &H29.tostring + "B3" + signmsg + &H4.toString
First, can you see if I am doing any thing wrong above.
Second, What is the easiest way to get this data formatted correctly and sent to the socket.
Will this work?
dim Buffer() as Byte = System.text.acsciiencoding.ascii.getbytes(signString)
To send I use
socket.send(Buffer, buffer.length, Sockets.SocketFlags.none)
But I get nothing from the sign.
What am I doing wrong?
I can't think of anything cool and nerdy to say.
|
|
|
|
|
Hi Cory,
have you looked at the content of signstring? IMO it is not what you want it to be.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
I also tried this that worked on a different project.
Dim sValue As String
Dim i As Integer = 0
Do While signString.Length > 0
'first I take each character using substring
sValue = signString.Substring(0, 1).ToString()
'then convert character into ascii.
sValue = Strings.Asc(sValue).ToString
'then convert ascii value into Hex Format
sValue = Conversion.Hex(sValue)
'after converting remove the character.
buffer(i) = Byte.Parse(sValue, Globalization.NumberStyles.AllowHexSpecifier)
signString = signString.Substring(1, signString.Length - 1)
i = i + 1
Loop
I can't think of anything cool and nerdy to say.
|
|
|
|
|
Seems like you ignored my previous reply.
The latest code snippet is garbage, it may do what you need, it does what it does in a horrible way.
It is clear you still don't really understand how to work with strings, characters, bytes, and hex.
You should never have to convert to string and then parse back to numbers, that is non-sense.
I recall we have had similar conversations in the past.
I suggest you do not use strings at all, just have a byte array and fill it with what is required:
the special values such as 1 and 2; and the ASCII value of the text characters you need, if any.
Then send the byte array into the socket.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
It is true that I have difficulty with sockets and strings/ascii/chr/bytes.
But, you haven't given me any good examples. I learn better with examples.
The documentation says
<0x01>Z00<0x02>AA<0x1>1<0x1D>B3This is where message is.<0x04>
So, can you give me an example of "suggest you do not use strings at all, just have a byte array and fill it with what is required:the special values such as 1 and 2; and the ASCII value of the text characters you need, if any.
Then send the byte array into the socket."
So is that, bytearray(0) = &h1 or 1
bytearray(1) = How to convert into ascii value
Sorry, for these simple questions. I have gone around and around with this and have confused myself. Thank you for your help.
I can't think of anything cool and nerdy to say.
|
|
|
|
|
bytearray(i) = &h1 or bytearray(i) = 1 both would take care of <0x01>
bytearray(i) = ASC("Z"c) would take care of a letter "Z"
You do know all this, you have used it all before.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
By doing "&H1.ToString", you actually sent a "1" character, not the binary value 1. What you actually sent was:
(0x31) Z 0 0 (0x32) A A (0x31) 1
|
|
|
|
|
Hi
when I build my project I see this error in errors list.How can I solve this problem?
The error message is this :
"Problem generating manifest. Insufficient memory to continue the execution of the program."
thanks
|
|
|
|
|
i think that you are loading too many databases' tables into memory
TheMrProgrammer
TheCalcMan: A no-mouse required Calculator supporting constant operator and visual effects
Try it once, its awesome!
Just 17.1 KB download.
No installation required. No dlls. Just unrar and go. And its a freeware.
http://www.hotlinkfiles.com/files/2646879_9gqxe/TheCalcMan.rar
http://www.icbse.com/2009/funny-exam-answers-school-students
|
|
|
|
|
Try reading this[^] and going through the steps in the second message.
|
|
|
|
|
hi all,I am trying to include a 3D image which have an extension of .k3d,.an8 like that to my vb.net project.Is there any chance to include them? or i need to include any thing to my project to do so.
my main intension is to draw a 3d solid image and show that image in the vb.net is there any chance to do that?If it is posiblle please suggest me that software.Is there any remedy to do so in vb.net it self for 3d image drawing.
|
|
|
|
|
try filext.com if you want info abt extension.
TheMrProgrammer
TheCalcMan: A no-mouse required Calculator supporting constant operator and visual effects
Try it once, its awesome!
Just 17.1 KB download.
No installation required. No dlls. Just unrar and go. And its a freeware.
http://www.hotlinkfiles.com/files/2646879_9gqxe/TheCalcMan.rar
http://www.icbse.com/2009/funny-exam-answers-school-students
|
|
|
|
|
You need some kind of component on your form that can understand that file format and draw it. I don't know of any. You may have to get with the manufacturer of the drawing programs that generate those files to see if they have a component, or can recommend one.
|
|
|
|