|
Well, to change the title bar, you may be able to set a color property, but I suspect you'd have to owner draw. To flash things on the form, is far easier. Just set a timer to fire and alternate some colors. Kill it after a particular number of iterations.
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 )
|
|
|
|
|
I wouls love to alternate some colours, as of yet have not figure out how to do it.
what i have in my timer_tick is...
me.background = color.yellow
Is there a way to randomly select a .color
|
|
|
|
|
You can build an array and select from there, or select the red/green/blue components at random
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 )
|
|
|
|
|
Yes, use a random class and three integers.
Dim Ran as new random<br />
dim R as integer = ran.next(0,255)<br />
dim G as integer = ran.next(0,255)<br />
dim B as integer = ran.next(0,255)<br />
<br />
me.backgroundcolor = color.fromargb(r,g,b)
Your getting three random numbers, rgb values, and making a color out of it.
|
|
|
|
|
Hello!
I have a 'Panel' and have placed differnt RTF text boxes and differnt locations on the Panel. I can drag these text boxes, at runtime, anywhere on the panel. What i want is: When i press the "Print" button all the RTF text within "RTFTextBoxes" should be printed to paper exactly at the location where Text Box is located on the Panel.
My core problem is how can i print RTF text from each individual RTB at specified location.
Thank you for any help!
colgateas900197
|
|
|
|
|
|
Another possibility would be to drop a Form Print Component[^] on your form and set the extended properties e.g. Print to True, BoundingRectangle to whereabouts on the page you want it to appear, and set RTFPrintMethod to print out the rich text box in what-you-see-is-what-you-get ...
|
|
|
|
|
Sir i m trying with an challanging asigmnent to work with editing textfiles in vb6.0 i had file which looks as below :
Color|Fruits|series|IN|OUT|NET|VAL|
Black|Mango |001|1000|2000|-1000|1.5|
white|banana|001|100 | 20| 80|1.5|
white|cherry|001|1000|1000| 00|1.5|
Black|almond|001| 20| 80| -60|1.5|
i m trying to get data and save in seperate file which in below format :
COLORS,FRUITS,NET,(+/-QTY)
B ,BANANA,20,1
W ,ALMOND,60,2
Here following conditions should me matched
1) NET column sholud be greater than 0 and less than 100 also less than -1 and greater than -100 but should not be 0
2)select only fruit column and color column from previoustext file
plz provide me guidance as soon as possible i m stuck with this problem thank u
JACK
|
|
|
|
|
Do your own homework.
Paul Marfleet
|
|
|
|
|
Why are people being taught VB6 ? You may as well raise your kids to speak Latin. Except no-one will think you're stupid for knowing Latin.
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 all
First off im a student, but this is Not an assignment, it's the end of degree project!.. so im kinda freakin out a bit.
i dont want a handout, just a point in the right direction.
Ive built this application, like a floorplan viewer that has network devices on the map, works great, but now my business client wants to make it distributed, and run it as a service.
i have used a previous chatroom that i built to use for a test case, to see if i could host a remoting server in a service. the chatroom works fine its very simple, which is why i thought it would be a good test for using remoting in a service. for the test case (and confidentialy) ive decided its better to post this chatroom that i converted to a service instead of the real app.
The problem is the same with both the chatroom and the floorplan app,
1. the service starts fine, creates proxy, a successful event log is written.
2. start the client, proxy created, then on the first proxy method call i get this error...
************** Exception Text **************
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'ClientGUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'ClientGUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Reflection.MemberInfoSerializationHolder..ctor(SerializationInfo info, StreamingContext context)
=== Pre-bind state information ===
LOG: User = NT AUTHORITY\SYSTEM
LOG: DisplayName = ClientGUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/chat/MyService/bin/Release/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI.DLL.
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI/ClientGUI.DLL.
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI.EXE.
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI/ClientGUI.EXE.
--- End of inner exception stack trace ---
Server stack trace:
at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)
at System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context)
at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessage(String objectUri, Stream inputStream, Boolean bStrictBinding, TypeFilterLevel securityLevel)
at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at SharedClasses.IServer.Connect(Parcel msgDel, Parcel usrDel, String userName)
at ClientGUI.ClientForm.btnConnect_Click(Object sender, EventArgs e) in C:\chat\ClientGUI\ClientForm.vb:line 41
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
ClientGUI
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/chat/ClientGUI/bin/Release/ClientGUI.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
SharedClasses
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/chat/ClientGUI/bin/Release/SharedClasses.DLL
----------------------------------------
the questions i guess i have are...
How do i tell it where to find the assembly?,
why does this not happen when it is not run as a service.. it works fine. i got good marks for it!
i really havent dealt with assemblys and namespaces (conciously) and this stuff, but keen as to figure this out.
Can anyone point me in the right direction?
Project code is below
Many thanks
red
|
|
|
|
|
Code for Service:
Imports System.Runtime.Remoting
Imports MyServer
Imports SharedClasses
Public Class MyService
Private proxy As Server
Protected Overrides Sub OnStart(ByVal args() As String)
RemotingConfiguration.Configure("C:\chat\MyService\bin\Release\ServerForm.config", False)
proxy = CType(Activator.GetObject(Type.GetType("SharedClasses.IServer, SharedClasses"), "tcp://localhost:8085/yakkityYak"), SharedClasses.IServer)
Dim objEventLog As New EventLog()
objEventLog.Source = "MyService"
objEventLog.WriteEntry("proxy created")
'StartTimer()
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
End Sub
End Class
Code for Server:
Imports SharedClasses
Public Class Server
Inherits MarshalByRefObject
Implements IServer
Private htMsgDel As New Hashtable
Private htUsrDel As New Hashtable
Public msgDel As IServer.msgCallBack
Public usrDel As IServer.usrCallBack
Public Function Connect(ByVal msgParcel As Parcel, ByVal usrParcel As Parcel, ByVal userName As String) As Boolean Implements IServer.Connect
SyncLock GetType(Server)
Dim connected As Boolean
If Not htUsrDel.ContainsKey(userName) Then
htMsgDel.Add(userName, msgParcel.msgDel())
htUsrDel.Add(userName, usrParcel.usrDel())
BroadcastUsers(userName)
connected = True
Else
MsgBox("The username " & userName & " is not available.")
End If
Return connected
End SyncLock
End Function
Public Sub disConnect(ByVal userName As String) Implements SharedClasses.IServer.disConnect
SyncLock GetType(Server)
htMsgDel.Remove(userName)
htUsrDel.Remove(userName)
BroadcastUsers(userName)
End SyncLock
End Sub
Public Sub BroadcastUsers(ByVal senderName As String) Implements IServer.BroadcastUsers
Dim alUsers As New ArrayList
For Each userName As String In htUsrDel.Keys
If Not userName = "server" Then
alUsers.Add(userName)
End If
Next
For Each userName As String In htUsrDel.Keys
If Not userName = senderName Then
usrDel = htUsrDel.Item(userName)
usrDel(alUsers)
End If
Next
End Sub
Public Sub Message(ByVal msg As String, ByVal userName As String) Implements IServer.Message
SyncLock GetType(Server)
For Each user As String In htMsgDel.Keys
If Not user = userName Then
msgDel = htMsgDel.Item(user)
msgDel(userName & ": " & msg & vbCrLf, userName)
End If
Next
End SyncLock
End Sub
Public Function getUsers() As ArrayList Implements IServer.getUsers
Dim alUsers As New ArrayList
For Each userName As String In htMsgDel.Keys
alUsers.Add(userName)
Next
Return alUsers
End Function
Public Sub TickMessage(ByVal msg As String) Implements IServer.TickMessage
SyncLock GetType(Server)
For Each user As String In htMsgDel.Keys
If Not user = "server" Then
msgDel = htMsgDel.Item(user)
msgDel(msg & vbCrLf, user)
End If
Next
End SyncLock
End Sub
End Class
Code for Server config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref="tcp" port="8085">
<serverProviders>
<provider ref="wsdl" />
<formatter ref="soap" typeFilterLevel="Full" />
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
<clientProviders>
<formatter ref="binary" />
</clientProviders>
</channel>
</channels>
<service>
<wellknown type="MyServer.Server, MyServer" objectUri="yakkityYak" mode="Singleton" />
</service>
<!-- <lifetime leaseTime="10S" sponsorshipTimeOut="10S" renewOnCallTime="5S"/> -->
</application>
</system.runtime.remoting>
</configuration>
Code for Client:
Imports System.Runtime.Remoting.Channels.ChannelServices
Imports System.Runtime.Remoting.Channels.TCP
Imports SharedClasses
Public Class ClientForm
Private IPAddress As String
Private userName As String
Private proxy As IServer
Public msgDel As IServer.msgCallBack
Public usrDel As IServer.usrCallBack
Private myConfiguration As Configuration
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn.Click
If txtUserName.Text = "" Then
MsgBox("enter a user name please")
txtUserName.Focus()
ElseIf Not txtUserName.Text.Length <= 13 Then
MsgBox("user name must be 13 characters or less")
txtUserName.Focus()
Else
Dim chan As TcpChannel
chan = New TcpChannel(0)
RegisterChannel(chan, False)
proxy = Activator.GetObject(Type.GetType("SharedClasses.IServer, SharedClasses"), "tcp://localhost:8085/yakkityYak")
' Send message delegate
msgDel = AddressOf msgCallBack
Dim msgParcel As Parcel = New Parcel(msgDel)
usrDel = AddressOf usrCallBack
Dim usrParcel As Parcel = New Parcel(usrDel)
userName = txtUserName.Text
Try
Dim connected As Boolean = proxy.Connect(msgParcel, usrParcel, userName)
If connected Then
btn.Enabled = False
btnSend.Enabled = True
txtUserName.Enabled = False
Me.Text = "Client : " & txtUserName.Text
ToolStripConnect.Text = "Connected"
For Each user As String In proxy.getUsers()
If Not user = "server" Then
lstUserNames.Items.Add(user)
End If
Next
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If
End Sub
Private Sub ClientForm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Not proxy Is Nothing Then
proxy.disConnect(userName)
End If
End Sub
Public Sub usrCallBack(ByVal userNames As ArrayList)
lstUserNames.Items.Clear()
For Each user As String In userNames
lstUserNames.Items.Add(user)
Next
End Sub
Public Sub msgCallBack(ByVal msg As String, ByVal userName As String)
rtbMessages.AppendText(msg)
End Sub
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
If Not txtMessage.Text = "" Then
proxy.Message(txtMessage.Text, userName)
msgCallBack(userName & ": " & txtMessage.Text & vbCrLf, userName)
txtMessage.Text = ""
txtMessage.Focus()
End If
End Sub
Private Sub ClientForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
btnSend.Enabled = False
IPAddress = "localhost"
End Sub
Private Sub contextUser_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles contextUser.Opening
If Not lstUserNames.SelectedIndex = -1 Then
MsgBox(lstUserNames.SelectedItem.ToString)
End If
End Sub
Private Sub mnuConfiguration_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuConfiguration.Click
If myConfiguration Is Nothing Then
myConfiguration = New Configuration
End If
myConfiguration.Show()
End Sub
End Class
Code for serializable object
<Serializable()> Public Class Parcel
Private msgDelegate As IServer.msgCallBack
Private usrDelegate As IServer.usrCallBack
Public Sub New(ByVal del As IServer.msgCallBack)
msgDelegate = del
End Sub
Public Sub New(ByVal del As IServer.usrCallBack)
usrDelegate = del
End Sub
Public ReadOnly Property msgDel() As IServer.msgCallBack
Get
Return msgDelegate
End Get
End Property
Public ReadOnly Property usrDel() As IServer.usrCallBack
Get
Return usrDelegate
End Get
End Property
End Class
code for interface to server
Public Interface IServer
Delegate Sub msgCallBack(ByVal s As String, ByVal userName As String)
Delegate Sub usrCallBack(ByVal userNames As ArrayList)
Function Connect(ByVal msgDel As Parcel, ByVal usrDel As Parcel, ByVal userName As String) As Boolean
Sub disConnect(ByVal userName As String)
Sub Message(ByVal msg As String, ByVal userName As String)
Sub TickMessage(ByVal msg As String)
Sub BroadcastUsers(ByVal senderName As String)
Function getUsers() As ArrayList
End Interface
code for the server Gui ***** not used anymore, this is what the service is replacing... hopefully...
Imports System.Runtime.Remoting
Imports MyServer
Imports SharedClasses
Public Class ServerForm
Private proxy As New Server
Public msgDel As IServer.msgCallBack
Public usrDel As IServer.usrCallBack
Private Sub ServerForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mnuShutdown.Enabled = False
Timer1.Enabled = True
End Sub
Private Sub StartServerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuStart.Click
'configure server
RemotingConfiguration.Configure("ServerForm.config", False)
proxy = CType(Activator.GetObject(Type.GetType("SharedClasses.IServer, SharedClasses"), "tcp://localhost:8085/yakkityYak"), IServer)
'setup delegates
msgDel = AddressOf MsgCallBack
Dim msgParcel As Parcel = New Parcel(msgDel)
usrDel = AddressOf usrCallBack
Dim usrParcel As Parcel = New Parcel(usrDel)
'connect to proxy
Dim connected As Boolean = proxy.Connect(msgParcel, usrParcel, "server")
mnuStart.Enabled = False
mnuShutdown.Enabled = True
toolStripConnect.Text = "Server Started"
End Sub
Public Sub MsgCallBack(ByVal msg As String, ByVal userName As String)
rtbMessages.AppendText(msg)
End Sub
Public Sub usrCallBack(ByVal userNames As ArrayList)
lstUserNames.Items.Clear()
For Each user As String In userNames
lstUserNames.Items.Add(user)
Next
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
proxy.TickMessage("sss")
MsgBox("x")
End Sub
End Class
thanks for your time
|
|
|
|
|
Solved... i didnt have a copy of the client in the servers folder, so as it said, ....FileNotFoundException... doh!
|
|
|
|
|
I have this question :
A gas pump calculates the cost of gas at a local gas station. The station charges 2.09 per gallon for regular grade gas, $2.16 per gallon for special grade gas and $2.26 per gallon for the super grade gas. The click event handler for each button calls a method to compute the total cost
from the number of gallons entered and the selected grade.
I have attempted this way :
Public Class FrmGasolineCalculator
Inherits System.Windows.Forms.Form
'Labels for the form are defined here
Friend WithEvents lblTitle As System.Windows.Forms.Label 'Title label
Friend WithEvents lblLabel1 As System.Windows.Forms.Label 'Label to prompt user input
Friend WithEvents lblLabel3 As System.Windows.Forms.Label 'Label to display the output
'Read one number from the user as an input
Friend WithEvents txtInput As System.Windows.Forms.TextBox
Friend WithEvents txtResult As System.Windows.Forms.Label 'Result will be displayed here
'Reads input and calculates result accordingly
Friend WithEvents btnRegular As System.Windows.Forms.Button
Friend WithEvents btnSpecial As System.Windows.Forms.Button
Friend WithEvents btnSuperplus As System.Windows.Forms.Button
Dim result As Decimal
Function Calculate(ByVal Total As Decimal) As Decimal
Dim Quantity As Integer = 0
txtInput.Text = Convert.ToInt32(Quantity)
Total = 0
Dim Cost As Decimal
Select Case Cost
Case 2.09
Total = Quantity * 2.09
Return Total
Case 2.16
Total = Quantity * 2.16
Return Total
Case 2.26
Total = Quantity * 2.26
Return Total
End Select
End Function
Private Sub Regular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Regular.Click
txtResult.Text = Convert.ToDecimal(result)
result = 0
If Not txtInput.Text = " " Then
result = Calculate(result)
End If
End Sub
End Class
I have not handled the other two buttons Special and Superplus because the programming will be the same.
Error is :
Object reference not set to an instance of an object. How to handle this ?
Thanks
|
|
|
|
|
Hi,
a couple of remarks:
1.
all errors show line numbers:
- compile errors mention file name and line number
- run-time exceptions show complete stack traceback with line numbers
2.
Visual Studio can be told to show line numbers in the left margin of the editor,
see Options/Tools/TextEditor
3.
combining 1 and 2, if something goes wrong you can easily determine where the error
occured.
4.
I have never seen cases with decimal values, but I doubt you need them.
What happened to TotalCost = Quantity * UnitCost ?
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi all
sorry to trouble you.
actually my problem is i have to split one large file into small files.
based on these conditions, i have maximum file size and minimum file size.
to split the large file into smaller ones,the child file should be either maximum size or greater than minimum size and less than maximum size.
iam struggling to write the logic,plese help me to write the logic.
suppose for example large filesize is 1050MB and max size is 100MB and minimmum size is 90MB.i have to split first as many as possible max size files and remaining are in between max and minimum size.
advancedly thanks to giving replies
Thanks&Regards
RENU
|
|
|
|
|
I remember answering the same question a while back. Search in the forum and see if you can find it.
---
single minded; short sighted; long gone;
|
|
|
|
|
Yes, tell your teacher/professor to give you different homework, since that one
can be found everywhere on the web.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I have created an application in vb .NET using ODBCConnection Object (for MS-Access). this is a MDI Application. when i am running this Exe thru the network it is showing following error-
[Request for the permission of type 'System.Data.Odbc.OdbcPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
Error in SQL Connection
I Want to solve this problem thru code in 'VB .NET'. I do not want to do this manually as we do from "Control Panel->adminstrative tool->MS .NET Framework2.0 Configuration" How can i solve this problem. Please help me.
my mail ID is kkb_mda@yahoo.co.in
Thanks and Regards
Kishore
|
|
|
|
|
You asked this yesterday and were given the correct answer. You have NO CHOICE but to read up on and understand Code Access Security[^].
You're getting this exception because code executed from an non-local (read: network) source is NOT TRUSTED and runs in a heavily restricted sandbox. You have to tell the machines running the code to trust the source of the code to get more permissions.
|
|
|
|
|
Dear All im a newbie to scripting so please go easy on me.
Ive nearly finished my script but im stuck on the last points.
I need to append data in "Column A" created early in the script (groupmember.csv) with the data that is outputted by the password software last in the script, Currently its a .txt (newpasswords.txt) but could be a .csv.
Help please
thanks
paul
Option Explicit
Dim strCN, strFilter, objShell, strCmd, filePath
Dim oExcel, oSheet
' Prompt for group names and construct the filter.
strCN = ""
strFilter = "(|"
Do
strCN = InputBox("Enter Common Name of a group or Cancel", "Test")
If (strCN <> "") Then
strFilter = strFilter & "(memberOf=cn=" & strCN _
& ",ou=MYOU,dc=DOMAIN,dc=co,dc=uk)"
End If
Loop While strCN <> ""
strFilter = strFilter & ")"
' Use the WshShell object to run the csvde command.
If strFilter <> "(|)" Then
filePath = "d:\get-group\GroupMember.csv"
Set objShell = CreateObject("Wscript.Shell")
strCmd = "%comspec% /c csvde -f " & filePath & " -r """ & strFilter & """"
strCmd = strCmd & " -l givenName,userPrincipalName"
strCmd = strCmd & " -s SERVER.DOMAIN.co.UK"
objShell.Run strCmd, , True
'Deletes line 1 from GroupMember.csv
Const xlUp = -4162
Const xlLeft = -4131
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oExcel.Workbooks.Open filePath
Set oSheet = oExcel.ActiveWorkbook.Worksheets(1)
oSheet.Rows(1).Delete xlUp
'deletes Column A from GroupMember.csv
oSheet.Columns(1).Delete xlLeft
Dim c
For Each c In oSheet.UsedRange.Columns(1).Cells
c.Value = Left(LCase(c), 3)
Next
' saves the file
oExcel.DisplayAlerts = False
oExcel.ActiveWorkbook.SaveAs filePath
oExcel.ActiveWorkbook.Close
oExcel.Quit
Set oSheet = Nothing
Set oExcel = Nothing
End If
' send commandline parameters to Password Generator Professional
Set wshShell = WScript.CreateObject ("WSCript.shell")
wshShell.run """C:\Program Files\Kristanix\Password Generator Professional\PGP.exe"" /output ""d:\get-group\newpasswords.txt"" /format ""$p"" /quantity 1600 /showmsg /unique /mask ""{N:n,3,3}{N:s,1,1}""", 6, True
set wshshell = nothing
|
|
|
|
|
I always love when someone says that they're "nearly finished", but yet half their code still needs to be written...
To translate what I THINK you're trying to say, you want to read the passwords from a text file and put them in Column B of this Excel sheet??
Since it looks like you already know how to use the Excel object model, all you would need to do is use a FileSystemObject to open and read the passwords file, line by line, and put the password in the cell you're keeping track of, until you reach the end of the file.
|
|
|
|
|
Hi there Dave thank you so much for your reply.
(when i say nearly there ive only one more step to go on paper anyway !!!)
Sorry if my description was garbled
Yes i want to read the passwords from a text file.
But i want to add them INTO Col A (APPEND T0)
(Col A already contains info [First 3 chars of forename in LC] )
Column A will then be read by an app my developers are creating which will reset the users password to that in Col A.
Dave,
Im really feeling my way in the dark and have just been playing until i get somthing that works as im really new to scripting anything of consiquence.
Its the appending part that i suppose im really stuck on.
Many kind Regards
Paul
|
|
|
|
|
OK. Same thing, only instead of assigning the string read from the password file to column B, you're combining strings in column A.
Cell(row,col).Value = Call(row,col).Value & TextLineFromFile
|
|
|
|
|
Hi Dave,
Thanks for that.
Ive managed to cobble together some code which will copy from a .TXT to Col A of a .CSV.
Whereabouts\how would i addin your suggestion of:
Cell(row,col).Value = Call(row,col).Value & TextLineFromFile
Where you say (row,col)does that mean i need to specify the row and column..as ive a lot of row data to add.
Code below
-----------------------------------------------------------------------------
Const ForReading = 1
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oExcel.Workbooks.Add
i = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\passwords.txt", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
arrLine = Split(strLine, ",")
oExcel.Cells(i, 1).Value = arrLine(0)
i = i + 1
Loop
oExcel.ActiveWorkbook.SaveAs ("c:\newtest.csv")
objFile.Close
oExcel.Quit
-----------------------------------------------------------------------------
|
|
|
|
|