|
I have a loop for a datagrid that shows all the amount rows added together in the caption.text of the datagrid. now i am going to change the loop because i dont need to add the rows, i need to subtract them. i know how to do that, but my question is that i have a textbox(textbox6) for which the user will need to enter a balance to show in the caption.text before the loop can subtract anything. any tips will be greatly appreciated.
this is what i have.
<br />
Dim t6 As Object<br />
<br />
t6 = TextBox6.Text<br />
For Each t As String In TextBox6.Text<br />
Amount += t<br />
Next<br />
<br />
Me.DataGrid1.CaptionText = "Current balance $" & t6.ToString()<br />
it is acting wierd. if i input 7 in the textbox then the data grid recieves only an addition of 1. if i input 9 it gets an addition of 4.why
Makniteasy
|
|
|
|
|
Sorry, but I dont get what you are trying to do...
You assign the Text of the textbox to the object variable t6 and print it out at the end. But in the loop you are only adding (I thought you want to substract something) values to the variable Amount.
And what is For Each t As String In TextBox6.Text supposed to do in your opinion? I dont think thats what you are really trying to perform...
|
|
|
|
|
I have an application where I first load a vb.net app that is going to run in the background. That app then starts another vb.net app that is the user interface (UI). Is there anyway I can send a message (or something) from my UI app to my background app so it can then start a process?
If so, how would that be done?
|
|
|
|
|
Dial the Net Automatically
i Need to connect to the Net? without display a connection dialog box.
i neet to force dial access to the Net, without any form of user intervention
|
|
|
|
|
Hi I am trying to call a Function from a Sub routine that basically does a WMI check and puts the results into a Variable.
Then from the main Sub routine Display the variable in the HTA app.
I'm sure the WMI function works ok but I'll be damed if I can get the variables to be displayed in the HTA app.
Here is a sample of the code Iam running, any help would be appreciated. Thanks
' ********* GET OS FUNCTION **********
Function GatherInformation
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & sComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM win32_OperatingSystem", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
strOperatingSystem_InstallDate = objItem.InstallDate
strOperatingSystem_Caption = objItem.Caption
strOperatingSystem_ServicePack = objItem.CSDVersion
strOperatingSystem_WindowsDirectory = objItem.WindowsDirectory
strHTML = strHTML & objItem.Caption
strHTML = strHTML & strOperatingSystem_Caption
Next
Set objWMIService = Nothing
GatherInformation = True
DataArea.InnerHTML = strHTML
End Function
' ********* END OS FUNCTION **********
' ******* PUT HTML IN THERE ***
Sub Display
strHTML = strHTML & strOperatingSystem_Caption & "hello"
DataArea.InnerHTML = strHTML
End Sub
' ********************************
' ********* Main Subroutine ***********
Sub MainSub
On Error Resume Next
DataArea.InnerHTML= " "
sComputer = ComputerTextBox.Value
If sComputer = Empty Then
strHTML = strHTML & "Please Enter a Computer Name "
DataArea.InnerHTML = strHTML
Else
If IsConnectible(sComputer,"","") Then
strHTML = strHTML & "Ping Successful"
If WMIPing(sComputer) Then
strHTML = strHTML & strOperatingSystem_Caption & "hello"
strHTML = strHTML & "WMI Connection Successful" & " "
Call GatherInformation
Set objWMIService = Nothing
GatherInformation = True
strHTML = strHTML & strOperatingSystem_Caption & "hello"
DataArea.InnerHTML = strHTML
Else
strHTML = strHTML & "WMI Connection Fail"
End If
Else
strHTML = strHTML & "Ping Fail"
End If
DataArea.InnerHTML = strHTML
End If
End Sub
|
|
|
|
|
pn1995 wrote:
Set colItems = objWMIService.ExecQuery("SELECT * FROM win32_OperatingSystem", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
Get rid of the wbemFlagReturnImmediately flag. It'll cause the ExecQuery call to retrun immediately, without waiting for any actual data to come back. You're variables are then getting assigned blank strings because, obviously, you didn't wait for the ExecQuery call to return any data!
[EDIT]
Replace it with the wbemFlagReturnWhenComplete instead. It'll cause the call to block until some actual data is returned.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for replying but I tried both getting rid of the wbemFlagReturnImmediately and also trying replacing it with wbemFlagReturnWhenComplete but both still did not help in me being able to display any data from the variables. Any other ideas?
|
|
|
|
|
I have some data in a datagrid. i filled it before. than i want to delete a record from database. after my delete command it is deleted from datagrid but it is not deleted from database because after i start the program i can see it on the datagrid again. what might be problem?
while i add a record on the same database i'm not seing that problem.
Thank you.
|
|
|
|
|
It me bay deleted from the datasource, but not from the database. You should check your Delete Command to see what happens.
Good luck.
sebastien.lachance.blogspot.com
|
|
|
|
|
I'm wanting to write a program similar to the Server Manager Program that comes with Windows 2000 server. I want to be able to choose a single file, and see all the users currently using that file. Any direction would be greatly appreciated.
Thanks
Gerry
|
|
|
|
|
- how to do i read data from .txt file
- pass the data i.e (xx,yy,zz) into my vb .net program
- display the data in tables
|
|
|
|
|
bizjosh wrote:
how to do i read data from .txt file
The File class.
bizjosh wrote:
pass the data i.e (xx,yy,zz) into my vb .net program
If you know the file format, then you can use Convert.ToXXX to change strings to other types.
bizjosh wrote:
display the data in tables
Put it in an arraylist and use a datagrid.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Dim reader as new System.IO.Streamreader(full file path)
'This is a serial reader, so once you iterate, you cannot go to the previous line unless you reopen the file and iterate to the patricular line number
'Say you want to read your data which is in the format xx,yy,zz
Dim str as String
Dim split_str() as String 'Dynamic String Array
str = reader.readLine() 'Assuming your data is in the first line of the file
split_str = str.split(',')
'You will get an array which made by tokenizing string using "," as the delimiter. Now split_str(0) = xx, split_str(1) = yy, split_str(2) = zz. You can further parse them to the required format that you want for further prcessing.
'Do not forget
reader.close()
Go to MSDN.com and verify the syntax for String.split(args[]). The context is the same but the delimiter might be a char or string or ASCII code, you might wanna verify that. I think that should help you get started on reading text files.
|
|
|
|
|
I'm not sure i understand 100% what you are wanting to do, but if you want to read .txt (.csv, etc) file and place the data in a data grid, this is one way to do it.
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim data_table As New DataTable("Contacts")
' Define the columns.
data_table.Columns.Add("Last Name", GetType(String))
data_table.Columns.Add("First Name", GetType(String))
data_table.Columns.Add("Phone Number", GetType(String))
data_table.Columns.Add("Email Address", GetType(String))
' Create some data.
AddTableRow(data_table, "Jackson", "Jennie", "787-878-8263", "JennieJackson@nowhere.com")
AddTableRow(data_table, "Kevlar", "Kurt", "872-348-7263", "kurtk@militant.com")
AddTableRow(data_table, "Llama", "Linda", "", "lllama@weaver.com")
AddTableRow(data_table, "Mandrake", "Marcus", "398-787-4764", "marcus@marcusrocks.com")
' Bind the DataTable to the DataGrid.
dgContacts.DataSource = data_table
End Sub
Private Sub AddTableRow(ByVal data_table As DataTable, ByVal last_name As String, ByVal first_name As String, ByVal phone_number As String, ByVal email_address As String)
Dim data_row As DataRow
data_row = data_table.NewRow()
data_row.Item("Last Name") = last_name
data_row.Item("First Name") = first_name
data_row.Item("Phone Number") = phone_number
data_row.Item("Email Address") = email_address
data_table.Rows.Add(data_row)
End Sub
If you are using a datagrid you have to give it some fieldname info and that is what the first section (Define the columns) is for.
If this isn't what you are looking for, then there is a way you can use a SQL Text Driver and process your .txt file with an SQL table. Let me know if you think that would work better and I will show you that code.
|
|
|
|
|
In .Net When you Load the Recordset to datatable.If you set source of data to controls like listbox or combobox some times the datas are not viewed instead of In control we see the form of System.Data.DataRowView(It happenes only in sometime not all time )but we can avoid it through dataview
For example
dim dt as datatable
Adapter.Fill(dt)
ComboBox.Datasource = dt
ComboBox.DisplayMember="Column1"
ComboBox.ValueMember = "Column2" // In my case Display member displays record well but problem in Valuemember only i got as system.Data.DataRowView
you can avoid this in DirectCasting of DatarowView
Otherwise
dim dv as dataview = dt.DefaultView
ComboBox.Datasource = dv
ComboBox.DisplayMember="Column1"
ComboBox.ValueMember = "Column2" // Now works fine
Otherwise you can directly give as
ComboBox.Datasource = dt.Defaultview
ComboBox.DisplayMember="Column1"
ComboBox.ValueMember = "Column2" // Now works fine
I dont know why its happened,If anybody knows ,Let inform here
Rugfy
|
|
|
|
|
Hi,
I have created a Windows UserControl. This Control hosts a PropertyGrid and a Button control. The UserControl
project also includes a class called "TestClass" and a custom TypeConvertor class called "DDConv".
When the user clicks on the Button control, the application assigns an instance of "TestClass" to the PropertyGrid.
The "TestClass" has a property called "CustProp" and it has an TypeConverter attribute assigned to
the "CustProp" property. The TypeConvertor points to the "DDConv" class.
The PropertyGrid in the UserControl displays a DropDown against the "CustProp" property when the UserControl is
hosted in a windows application.
When the UserControl is hosted in Internet Explorer, the PropertyGrid does NOT SHOW any DropDown for the "CustProp"
property.
NOTE: I test the UserControl in Internet Explorer from a virtual directory on my machine. I have set "FullTrust" for
the "LocalIntranet_Zone" on my machine.
I want the PropertyGrid to display the DropDown in Internet Explorer - can someone help me in figuring out how to
acheive the same?
<br />
'TestClass.vb<br />
Public Class TestClass<br />
Dim _name As String<br />
Dim _ddProp As String<br />
<br />
Public Property Name() As String<br />
Get<br />
Return _name<br />
End Get<br />
Set(ByVal Value As String)<br />
_name = Value<br />
End Set<br />
End Property<br />
<br />
<System.ComponentModel.TypeConverter(GetType(DDConv))> _<br />
Public Property CustProp() As String<br />
Get<br />
Return _ddProp<br />
End Get<br />
Set(ByVal Value As String)<br />
_ddProp = Value<br />
End Set<br />
End Property<br />
<br />
End Class<br />
<br />
'DDConv.vb<br />
Public Class DDConv<br />
Inherits System.ComponentModel.StringConverter<br />
<br />
Dim _values As String()<br />
Dim _restrictToList As Boolean<br />
<br />
Public Sub New()<br />
_values = New String() {"Yes", "No"}<br />
End Sub<br />
<br />
Public Overloads Overrides Function GetStandardValuesSupported(ByVal context As _<br />
System.ComponentModel.ITypeDescriptorContext) As Boolean<br />
<br />
Return True<br />
End Function<br />
<br />
Public Overloads Overrides Function GetStandardValues(ByVal context As System.ComponentModel.ITypeDescriptorContext) _<br />
As System.ComponentModel.TypeConverter.StandardValuesCollection<br />
<br />
Return New StandardValuesCollection(_values)<br />
<br />
End Function<br />
<br />
Public Overloads Overrides Function GetStandardValuesExclusive(ByVal context As _ <br />
System.ComponentModel.ITypeDescriptorContext) As Boolean<br />
<br />
Return _restrictToList<br />
End Function<br />
End Class<br />
Thanks & Regards,
Dhwanil Shah
dhwanil.shah@patni.com
|
|
|
|
|
Hi,
I "discovered" what was wrong with this - somehow IE was "looking" for the dll which had the TypeConverter - even when that was the DLL which exposed the UserControl that IE was hosting.
When the PropertyGrid tried to use a custom type converter - it tried to create an instance of a class from its fully qualified assembly name. While trying to create this instance, IE (or .NET Framework or PropertyGrid) tried to download the required DLL (again). IIS on the server kept on returning 401 (for whatever reason). That was the reason the TypeConverters were not working. I discovered all this by monitoring the requests and responses between IE and IIS (I used the Fiddler tool from Microsoft - available at http://www.fiddlertool.com)
While trying to resolve another problem in the application - I read Paul Wilsons blog at http://weblogs.asp.net/pwilson/archive/2003/05/30/8037.aspx. In that Tim Clamp gave refrence regarding how to make IE / .NET Framework understand how to locate and download the assemblies. Based on that, I was able to give IE / .NET Framework absolute location for the .DLL that was being hosted by IE.
Refrences -
1. WinForm UserControls in Internet Explorer
http://weblogs.asp.net/pwilson/archive/2003/05/30/8037.aspx
2. PRB: Runtime Probe Causes a Delay When You Load a Windows Forms Control in Internet Explorer
http://support.microsoft.com/default.aspx?scid=kb;en-us;814668
Regards,
Dhwanil Shah
|
|
|
|
|
hello,
my application asks the user to enter a few words and the application arrange these words to create a 15x 15 crossword puzzle .
do you know any alogrithm that can help me to arrange the words in a way that gets the best result
|
|
|
|
|
|
I have a web system which will display a crystal report for clients. It is written in Visual Studio 2003,VB.Net and Crystal Report which comes with VS2003, running on Windows 2000. It works very well. Now we moved to Windows XP and I cannot run the report again at design time. There is no change to my code. I got the following error: The LoadSaveReportException: Load Report Error. I searched all answers through the web. It seems that the LoadSaveReportException is thrown when the report engine cannot open the report file. Is there any difference between Windows 2000 and Windows XP? How to resolve it?
Thanks.
Bing Chen
|
|
|
|
|
I am trying run a solenoid/motor using vb.net out the lpt port. I know that I have to use windows api, but do not know how to figure out to use the api. Can any one help?
|
|
|
|
|
google inpout.dll or NTPort.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hi,
How can I make Control Array in VB.net.
Like
TextBox1(0)
TextBox1(1)
TextBox1(2)
TextBox1(3)
TextBox1(4)
Thanks !
|
|
|
|
|
You don't. Control arrays are a thing of the past.
You can mimic them by using the Handles caluse of the event signature though. Thsi allows multiple controls to send thier events all to a common event handler.
Private Sub Button1_Click(ByVal sender As System.Object,_
ByVal e As System.EventArgs)_
Handles Button1.Click, Button2.Click, Button3.Click
Select Case DirectCast(sender, Button).Name
Case "Button1"
MessageBox.Show("Button1!")
Case "Button2"
MessageBox.Show("Button2!")
Case "Button3"
MessageBox.Show("Button3!")
Case Else
End Select
End Sub
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
My Blog[^]
|
|
|
|
|
'I have an example that can help you.
'Sorry, my english is bad !
'This is the file "Form1.vb"
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(24, 320)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(80, 24)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(400, 357)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
' MsgBox("OK")
' Dim V(0) As Windows.Forms.Button
'With V(0)
'.Size = New System.Drawing.Size(152, 24)
'.Location = New System.Drawing.Point(64, 216)
'End With
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Dim tb(2) As TextBox
For n As Integer = 0 To 2
''Crea le caselle ditesto richieste
tb(n) = New TextBox
tb(n).Size = New System.Drawing.Size(400, 30)
tb(n).Location = New System.Drawing.Point(59, 40 + n * 40)
''Questo identifica il controllo TextBox
tb(n).Name = CStr(n + 1)
tb(n).Tag = CStr(n + 1)
tb(n).Text = CStr(n + 1)
''Viene aggiunto il controllo alla lista controlli
Me.Controls.Add(tb(n))
''Crea i gestori d''evento
'AddHandler tb.KeyPress, AddressOf TextBox_KeyPress
AddHandler tb(n).TextChanged, AddressOf TextBox_TextChanged
'AddHandler tb.MouseEnter, AddressOf TextBox_MouseEnter
'AddHandler tb.MouseLeave, AddressOf TextBox_MouseLeave
Next
End Sub
Private Sub TextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim s As String
s = sender.tag
CiSono(s)
End Sub
End Class
'This is the file "Module1.vb"
Module Module1
Public tb(2) As TextBox
Public Sub CiSono(ByRef s As String)
MsgBox(s)
End Sub
End Module
|
|
|
|
|