|
check out:
http://www.codeproject.com/cs/miscctrl/Ribbon_Panel.asp[^]
You probably are thinking that's not what I want (I know it's a ribbon control)
BUT the devoloper creats his ribbonbuttons himself (draws them, does the eventhandling,...) and that is what you want (you will need to adjust a bit but take a look at this code and you should be able to adjust it to what you want)
|
|
|
|
|
Thanks for your reply. I'm pretty much a novice, and battle enough with Visual Basic, so trying to cope with C# is a bit beyond me. Do you know of anything in VB?
|
|
|
|
|
|
How do I send Arguments to a form when I open it?
EG. frmMyForm.Show("MyOpenArgs")
(I know that wont work, but that's more or less what I'm looking to do)
_______________________________________________________________________
http://www.readytogiveup.com/[ ^]
"you can't forget something you never knew..." M. Du Toit
|
|
|
|
|
Hi,
I prefer this way:
- create an instance of your form
- make sure the class has one or more setter properties; use these to pass
1 or more parameters
- then Show it.
An alternative is:
- give your form class a second constructor that accepts parameters
- use that constructor to create the form's instance
- now Show it.
In the special case your form needs the command line, it could
fetch that itself through the Environment class.
|
|
|
|
|
hi all
i need to write the events of the titlebar of the form plz tell me how can do that.
thnx
|
|
|
|
|
what events do you think are present?
|
|
|
|
|
like click event, double click event etc
|
|
|
|
|
i don't think you can trap those events... maybe some api call but vb itself doesn't seem to allow it.
|
|
|
|
|
There are no events for the title bar of the form.
|
|
|
|
|
How about:
me.text = "Whatever you want here"
or:
dim whateverHere as string<br />
<br />
whateverHere = yourFunction<br />
<br />
me.text = whateverHere
The second one is more complete and probably better for your purposes.
Maybe that's what you were looking for. Hope it helps!
|
|
|
|
|
I Want To Programing Mobiles With VB
Can Any One Help Me?
Can You Send Me Any 3Th Part Program?
Tanks
Mogtabam
|
|
|
|
|
You mean vb.net? or vb6.
You nead to be more specific.
For vb.net theres the .Net Compact Framework[^] that works on Windows Mobile phones.
For vb6 i think theres probably no chance.
|
|
|
|
|
Hi
I Want Write Program For All Mobiles
Not For Only Windows Based Mobiles
Tanks.
Mogtabam
|
|
|
|
|
Then you can't use VB.NET for that. Not every mobile phone supports every language and runtime out there. If you want your application supported on EVERY phone out there, you'll have to rewrite your app in various languages to do that.
|
|
|
|
|
hi all
i working on an application like word
i need to zoom, resize the richtextbox as well as the font and other element on the richtext box accordingaly the size of richtextbox.
as in word
any idea, any documentation or any thing else
any kind of help is thankful
thnx in advance
|
|
|
|
|
well you need to create yourself a scale system.
Dim ZoomScale as decimal = 1 'for 100%<br />
Dim OriginalSize as Size = me.textbox.size<br />
Dim PreZoomFont as Font
then on when the user changes the zoom do this: If they put in an integer value, divide it by 100. Then multiply the textbox's width and height by this value and the font size by this value also.
For instance:
User enters: 135%
ZoomScale = 135/100 'Need to keep track of this so you can go back to 100 or any other scale.<br />
me.textbox.size = new size(me.textbox.width * Zoomscale, me.textbox.height * Zoomscale)<br />
'can't remember exactly how to do the font but i'm sure you'll figure that out.<br />
'This could need some work it's just conceptual
|
|
|
|
|
i think to use the ruler like control but i can't find any thing like that
i need to zoom but also make the richtextbox to change the size like a4 to letter or envelop
|
|
|
|
|
well...if you have those page measurements stored, a4 is 297 mm x 210 mm, then you can easily sort page size, for instance, set the width then adjust the height by the ratio of (298/210)
|
|
|
|
|
i need to preview text file in print_preview_dialog or print_preview_control with the text format every line with it's fomt and colors
i need very fast answer thanks alot
md_refay
|
|
|
|
|
i m not sure but u should make a printdocument for that and then u can preview any kind of text.
hope this will help u
|
|
|
|
|
Hi.. all
i'm new in visual basic.NET. Recently i make some program that running 24 hour, like server. When i test my code, i founded my usage of memory actually keep rising and make my computer hang.
So, can anyone give me some comment???
|
|
|
|
|
Call Dispose on any objects you are allowing to go out of scope, if it's offered.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi ...
Thanks to give me some comment.
I was call Dispose function to release any object that i created... but it my code still increase usage memory. in 8 hour, my memory increase 100 KBytes.
Actually i created some service application to accessing a serial port.
Here some code that i used to read a serial port continously:
'------------------------------------------------------------------------
Public Class PLC_Com
Dim MySerial As New System.IO.Ports.SerialPort
Dim MyTimer As System.Threading.Timer
Dim DataByte As Byte
Dim DataResult As String
Dim ReadStatus, WriteStatus As Integer
' Base Setting
Const def_ProtocolName As String = "Dedicated"
Const def_PortName As String = "COM1"
Const def_BaudRate As Integer = 57600
Const def_DataBits As Integer = 8
Const def_StopBits As Integer = 1 ' System.IO.Ports.StopBits.One
Const def_Parity As String = "None" ' System.IO.Ports.Parity.None
Const def_Handshake As String = "None" ' System.IO.Ports.Handshake.None
Const def_TimerInterval As Integer = 1000
Const def_WriteReadInterval As Integer = 100
Const def_RegCapacity As Integer = 1000
Const ACK As Char = Chr(6)
Const NAK As Char = Chr(21)
' Loading User Setting
Dim usr_ProtocolName As String = Nothing
Dim usr_PortName As String = Nothing
Dim usr_BaudRate As Integer = Nothing
Dim usr_DataBits As Integer = Nothing
Dim usr_StopBits As Integer = Nothing
Dim usr_Parity As String = Nothing
Dim usr_Handshake As String = Nothing
Dim usr_TimerInterval As Integer = Nothing
Dim usr_WriteReadInterval As Integer = Nothing
Dim usr_RegCapacity As Integer = Nothing
' System address
Dim ComStatus As String = Nothing
Dim RegIOCount As Integer = 0
Dim RegIOCountBuff As Integer = 0
Dim RegIOArray(3, 1) As String 'RegIOArray format (Command, Type, Value)
Const iRegCmd As Integer = 0
Const iRegMode As Integer = 1
Const iRegVal As Integer = 2
Dim i As Integer = 0
Dim BuffStr As String = Nothing
Public Sub New()
MyBase.New()
' This call is required by the Windows Form Designer.
InitializeComponent()
End Sub
'------------------------------------------------------------------------
' My Service start
'------------------------------------------------------------------------
Protected Overrides Sub OnStart(ByVal args() As String)
' Initilize Service Parameter, Reinitialize PLC IO Register buffer
Call Load_ServiceSetting()
ReDim RegIOArray(3, usr_RegCapacity)
Call Load_IO_Configuration()
' Delegating Timer event
System.IO.File.AppendAllText("C:\ServiceLog.txt", "MyService was started at : " & Now.ToString() & vbCrLf)
Dim tDelegate As Threading.TimerCallback = AddressOf EventAction
' Activation a timer
MyTimer = New System.Threading.Timer(tDelegate, Me, 0, usr_TimerInterval)
End Sub
Protected Overrides Sub OnStop()
System.IO.File.AppendAllText("C:\ServiceLog.txt", "MyService was stoped at : " & Now.ToString() & vbCrLf)
End Sub
'----------------------------------------------------------------
' FUNCTION SECTION
'----------------------------------------------------------------
Dim j As Integer = 0
Public Sub EventAction(ByVal sender As Object)
For RegIOCountBuff = 0 To RegIOCount - 1
If RegIOArray(iRegMode, RegIOCountBuff) = "R" Then
ComStatus = Read_PLC_Reg(RegIOArray(iRegCmd, RegIOCountBuff))
RegIOArray(iRegVal, RegIOCountBuff) = ComStatus
End If
If RegIOArray(iRegMode, RegIOCountBuff) = "W" Then
If j = 1000 Then j = 0 Else j += 1
RegIOArray(iRegVal, RegIOCountBuff) = CStr(j)
ComStatus = Write_PLC_Reg(RegIOArray(iRegCmd, RegIOCountBuff), j)
End If
Select Case ComStatus
Case "Error0"
System.IO.File.AppendAllText("C:\ServiceLog.txt", "NAK detected in PLC response with command " & RegIOArray(iRegCmd, RegIOCountBuff) & " at : " & Now.ToString() & vbCrLf)
Case "Error1"
System.IO.File.AppendAllText("C:\ServiceLog.txt", "Length of PLC response Not Valid with command " & RegIOArray(iRegCmd, RegIOCountBuff) & " at : " & Now.ToString() & vbCrLf)
Case "Error2"
System.IO.File.AppendAllText("C:\ServiceLog.txt", "No response from PLC with command " & RegIOArray(iRegCmd, RegIOCountBuff) & " at : " & Now.ToString() & vbCrLf)
Me.Stop()
Case "Error3"
System.IO.File.AppendAllText("C:\ServiceLog.txt", "Error while reading SerialPort at : " & Now.ToString() & vbCrLf)
Me.Stop()
End Select
System.Threading.Thread.Sleep(50)
Next
End Sub
Private Function Read_PLC_Reg(ByVal CmdString As String) As String
Try
DataResult = ""
If MySerial.IsOpen = False Then MySerial.Open()
MySerial.Write(Chr(5) & CmdString & Chr(4))
System.Threading.Thread.Sleep(usr_WriteReadInterval)
If MySerial.BytesToRead > 0 Then
For i = 0 To MySerial.BytesToRead - 1
DataByte = MySerial.ReadByte
DataResult += Chr(DataByte)
Next
If DataResult.Length > 14 Then
If Microsoft.VisualBasic.Left(DataResult, 1) <> NAK Then
Return Microsoft.VisualBasic.Mid(DataResult, 11, 4)
Else
Return "Error0"
Exit Try
End If
Else
Return "Error1"
Exit Try
End If
Else
Return "Error2"
Exit Try
End If
Catch ex As Exception
If MySerial.IsOpen Then MySerial.Close()
Return "Error3"
Exit Try
End Try
End Function
Private Function Write_PLC_Reg(ByVal CmdString As String, ByVal RegValue As String) As String
Try
DataResult = ""
If MySerial.IsOpen = False Then MySerial.Open()
MySerial.Write(Chr(5) & CmdString & StrTo4Str(Hex(RegValue)) & Chr(4))
System.Threading.Thread.Sleep(usr_WriteReadInterval)
If MySerial.BytesToRead > 0 Then
For i = 0 To MySerial.BytesToRead - 1
DataByte = MySerial.ReadByte
DataResult += Chr(DataByte)
Next
If DataResult.Length > 6 Then
If Microsoft.VisualBasic.Left(DataResult, 1) <> NAK Then
Return "OK"
Else
Return "Error0"
Exit Try
End If
Else
Return "Error1"
End If
Else
Return "Error2"
Exit Try
End If
Catch ex As Exception
If MySerial.IsOpen Then MySerial.Close()
Return "Error3"
Exit Try
End Try
End Function
Sub Load_ServiceSetting()
BuffStr = ""
Try
' Reading User setting from file
Dim FileSetting As New System.IO.StreamReader("C:\ServiceSetting.txt")
BuffStr = FileSetting.ReadLine
BuffStr = FileSetting.ReadLine
BuffStr = FileSetting.ReadLine
BuffStr = FileSetting.ReadLine
usr_ProtocolName = FileSetting.ReadLine
BuffStr = FileSetting.ReadLine
usr_PortName = FileSetting.ReadLine
BuffStr = FileSetting.ReadLine
usr_BaudRate = CInt(FileSetting.ReadLine)
BuffStr = FileSetting.ReadLine
usr_DataBits = CInt(FileSetting.ReadLine)
BuffStr = FileSetting.ReadLine
usr_StopBits = CInt(FileSetting.ReadLine)
BuffStr = FileSetting.ReadLine
usr_Parity = FileSetting.ReadLine
BuffStr = FileSetting.ReadLine
usr_Handshake = FileSetting.ReadLine
BuffStr = FileSetting.ReadLine
usr_TimerInterval = CInt(FileSetting.ReadLine)
BuffStr = FileSetting.ReadLine
usr_WriteReadInterval = CInt(FileSetting.ReadLine)
BuffStr = FileSetting.ReadLine
usr_RegCapacity = CInt(FileSetting.ReadLine)
FileSetting.Close()
FileSetting.Dispose()
Catch ex As Exception
usr_ProtocolName = def_ProtocolName
usr_PortName = def_PortName
usr_BaudRate = def_BaudRate
usr_DataBits = def_DataBits
usr_StopBits = def_StopBits
usr_Parity = def_Parity
usr_Handshake = def_Handshake
usr_TimerInterval = def_TimerInterval
usr_WriteReadInterval = def_WriteReadInterval
usr_RegCapacity = def_RegCapacity
System.IO.File.AppendAllText("C:\ServiceLog.txt", "Loading SerialPort deafault configuration at : " & Now.ToString() & ". Error : " & ex.ToString & vbCrLf)
Finally
' Seting up Serial Port parameter
MySerial.PortName = usr_PortName
MySerial.BaudRate = usr_BaudRate
MySerial.DataBits = usr_DataBits
Select Case usr_StopBits
Case 0 : MySerial.StopBits = System.IO.Ports.StopBits.None
Case 1 : MySerial.StopBits = System.IO.Ports.StopBits.One
Case 2 : MySerial.StopBits = System.IO.Ports.StopBits.Two
Case Else
MySerial.StopBits = System.IO.Ports.StopBits.None
End Select
Select Case usr_Parity
Case "None" : MySerial.Parity = System.IO.Ports.Parity.None
Case "Odd" : MySerial.Parity = System.IO.Ports.Parity.Odd
Case "Even" : MySerial.Parity = System.IO.Ports.Parity.Even
Case Else
MySerial.Parity = System.IO.Ports.Parity.None
End Select
Select Case usr_Handshake
Case "None" : MySerial.Handshake = System.IO.Ports.Handshake.None
Case "RequestToSend" : MySerial.Handshake = System.IO.Ports.Handshake.RequestToSend
Case "RequestToSendXOnXOff" : MySerial.Handshake = System.IO.Ports.Handshake.RequestToSendXOnXOff
Case Else
MySerial.Handshake = System.IO.Ports.Handshake.None
End Select
MySerial.Encoding = System.Text.Encoding.Default
System.IO.File.AppendAllText("C:\ServiceLog.txt", "SerialPort was initialized at : " & Now.ToString() & vbCrLf)
End Try
End Sub
Private Sub Load_IO_Configuration()
BuffStr = ""
RegIOCount = 0
Try
' Reading PLC IO Register from file
Using FileIOReg As System.IO.StreamReader = New System.IO.StreamReader("C:\ServiceIO.txt")
BuffStr = FileIOReg.ReadLine()
Do
BuffStr = FileIOReg.ReadLine()
If (BuffStr <> Nothing) Or (BuffStr <> "") Then
RegIOArray(iRegCmd, RegIOCount) = BuffStr
RegIOCount += 1
End If
Loop Until BuffStr Is Nothing
FileIOReg.Close()
FileIOReg.Dispose()
For i = 0 To RegIOCount - 1
RegIOArray(iRegMode, i) = Microsoft.VisualBasic.Mid(RegIOArray(0, i), 3, 1)
Next
End Using
System.IO.File.AppendAllText("C:\ServiceLog.txt", "PLC IO Register was initialized at : " & Now.ToString() & vbCrLf)
Catch ex As Exception
System.IO.File.AppendAllText("C:\ServiceLog.txt", ex.ToString & vbCrLf) '"Error while reading PLC IO Register "
End Try
End Sub
Private Function StrTo4Str(ByVal Data As String) As String
Dim Hasil As String = ""
Select Case Len(Data)
Case 1 : Hasil = "000" & Data
Case 2 : Hasil = "00" & Data
Case 3 : Hasil = "0" & Data
Case 4 : Hasil = Data
End Select
Return Hasil
End Function
End Class
the procedure :
Call Load_ServiceSetting()
ReDim RegIOArray(3, usr_RegCapacity)
Call Load_IO_Configuration()
is call when my service run fist time.
|
|
|
|
|
Don't keep things around that you no longer need; examples: when no longer needed
- a Form should be closed, not hidden;
- a file, a socket, ... should be closed;
- an object should be removed from whatever collection it happens to be in (List,
ArrayList,...).
As far as Dispose() goes, adding to what Christian said, most people seem to
forget Disposing of dialogs (don't know if that really is relevant to server software)
You are not calling CreateGraphics by any chance ? Most methods with create in their
name return objects that you should also dispose of.
|
|
|
|