|
Darn folks... Didn't mean to post this twice... I kept getting errors and didn't think it posted at all.
Sorry...
|
|
|
|
|
I have learned to deal with the way VB.NET has to be handled to create a control array but one thing still continues to bite me...
In VB6, if I had a bunch of label controls on a form that did nothing other than label things, I used to love to name them all the same name (thus creating a control array). Even if I was never going to use them as a control this way at least it gave me the ability to stop tons of controls that I was never going to have to reference from appearing in the dropdown box.
Now, when I go to select a control I have to wade through this long list of other controls that I am never going to use.
Am I missing something here?
|
|
|
|
|
hello everybody...
I require some help from the programmers. I want to have a program which could scan all the HDD present in the network with thier Volume Serial Number ....since Volume Serial Number is the only way to uniquely identify a HDD
and store the output to a Microsoft Access Database file.
At a particular amount of time it should tell that a particular HDD with this serial number is connected or not?
--thnx
waiting for a quick reply...
|
|
|
|
|
Okay, This is proably a no brainer for you folks but I am new to programming at this level, so please bear with me;
The Objective; to save the users input string to a cell after it has been verified.
The problem; when I run the code to debug it I currently get a "Runtime error 9 -subscript out of range" .
I would also ask that there must be a better way to store the password all suggestions are welcomed on that one and can anyone tell me what I need to use to mask the users input with a single repeated character.
Here's my current code:
<br />
Private Sub CommandButton2_Click()<br />
Dim Tb As Integer, PwdSv As String, Field As String<br />
<br />
Set Workbooks("XTSR").Sheets("Sheet14").Range("C17").Value = PwdSv<br />
Set Workbooks("XTSR").Sheets("Sheet14").Range("C6:C11").Value = Field<br />
<br />
For Tb = 1 To 6<br />
If Field = "" And PwdSv = "" Then Call password_new<br />
Next Tb<br />
If PwdSv <> "" Then Call Password<br />
End Sub<br />
<br />
Public Sub password_new()<br />
Dim Default, Msg1, Msg2, Style, Title1, Title2, PwdSv<br />
RESTART:<br />
Default = ""<br />
Msg1 = "Enter a Password"<br />
Msg2 = "Re-enter Password to Confirm it"<br />
Msg3 = "Entries Did Not Match, Try Again!"<br />
Set PwdSv = Workbooks("XTSR").Sheets("Sheet14").Range("C17").Value<br />
Title1 = "Password Confirmation"<br />
Title2 = "Password Error"<br />
Style = vbOKOnly + vbExclamation + vbApplicationModal<br />
Open "Ltrt.pws" For Output As #1<br />
strPwd1 = InputBox(Msg1, Title1, Default, 100, 100)<br />
strPwd2 = InputBox(Msg2, Title1, Default, 100, 100)<br />
Write #1, strPwd1, strPwd2<br />
Close #1<br />
Open "Ltrt.pws" For Input As #1<br />
Line Input #1, strData<br />
Close #1<br />
If strPwd1 = strPwd2 Then<br />
Set PwdSv = strPwd2<br />
Else<br />
Response = MsgBox(Msg3, Style, Title2)<br />
If Response.Value = 0 Then GoTo RESTART<br />
End If<br />
End Sub<br />
Public Sub Password()<br />
Dim Compare, PwdSv, Msg1, Msg2, Style, Title1, Title2<br />
Msg1 = "Please Enter Your Password"<br />
Msg2 = "Password Incorrect"<br />
Set PwdSv = Worksheet("Sheet14").Range("C17").Value<br />
Style = vbOKOnly + vbExclamation + vbApplicationModal<br />
Title1 = "Password Required"<br />
Title2 = "Password Volilation"<br />
Retry:<br />
Compare = InputBox(Msg1, Title1, 100, 100)<br />
If PwdSv = Compare Then Call ScreenFieldUnlock<br />
Else<br />
Response = MsgBox(Msg2, Style, Title2)<br />
If Response.Value = 0 Then GoTo Retry<br />
End Sub<br />
Public Sub ScreenFieldUnlock()<br />
TextBox1.Locked = False<br />
TextBox2.Locked = False<br />
TextBox3.Locked = False<br />
TextBox4.Locked = False<br />
TextBox5.Locked = False<br />
TextBox6.Locked = False<br />
UserForm1.Show<br />
End Sub<br />
The code I have here may be overkill but I wanted to be complete in the information and my inexperience shows I am sure. Hope someone can help I have spent a lot of time and getting no where on this one.
Roger
(Stubborn bulldog who like to go fast)
|
|
|
|
|
Please don't laugh. I am using MS Access to process text files. Right now it can process one file at a time. I want it to process an entire directory. Following is the current code for selecting the file for processing. can anyone help me modify this to automatically process the entire directory of text files.
Function Macro1()
On Error GoTo Macro1_Err
Dim stringFilename
stringFilename = InputBox("Enter the file:")
DoCmd.TransferText acImportFixed, "A Import Specification", "A", "c:\data\data1\" + stringFilename + ".txt", False, ""
Fred
|
|
|
|
|
Helo
What´s wrong when this Error commes up?
System.InvalidOperationException: Update requires a valid UpdateCommand when passed DataRow collection with modified rows. at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
What im trying to do is Updating a SQLServer Table with a offline updated Dataset. The Dataset is build by the .copy method. And the first table is identical to that on the SQLServer
|
|
|
|
|
hi
i want to update a table in databse using VB.NEt.. but i cant find a way to do it...
plz help me out
|
|
|
|
|
You should read this article, but change your name, it's a little creepy.
Nick Parker
|
|
|
|
|
I am having a problem with the datagrid. I needed a columnstyle to display a email link for each contact that is displayed in the detail portion of a master-detail form. I found an example of a combobox and modified it for to a linklabel (oddly enough it works ... this surprised me because I am completely lost with inherit, override, overload, etc. I think I'm down to two problems: I can't figure out how to handle the clicked link (this is kind of important!) and I would like to be able to change the background color of the label to match the alternating row color.
Thanks in advance for any help provided!!
Mark
Here is the code for the datagridlinklabel: (sorry for the length)
Option Strict On
Option Explicit On
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Data
Public Class DataGridLinkLabel
Inherits LinkLabel
Public Sub New()
MyBase.New()
End Sub
Public isInEditOrNavigateMode As Boolean = True
End Class
Public Class DataGridLinkLabelColumnStyle
Inherits DataGridColumnStyle
'
' UI constants
'
Private xMargin As Integer = 2
Private yMargin As Integer = 1
Private dgLinkLabel As DataGridLinkLabel
'
' Used to track editing state
'
Private OldVal As String = String.Empty
Private InEdit As Boolean = False
'
' Create a new column - DisplayMember passed by string
'
Public Sub New(ByVal DisplayMember As String)
dgLinkLabel = New DataGridLinkLabel()
With dgLinkLabel
.Visible = False
.Text = DisplayMember
End With
End Sub
Public Sub New()
dgLinkLabel = New DataGridLinkLabel()
With dgLinkLabel
.Visible = False
End With
End Sub
'------------------------------------------------------
' Methods overridden from DataGridColumnStyle
'------------------------------------------------------
'
' Abort Changes
'
Protected Overloads Overrides Sub Abort(ByVal RowNum As Integer)
Debug.WriteLine("Abort()")
RollBack()
HideLinkLabel()
EndEdit()
End Sub
Protected Overloads Overrides Function Commit(ByVal DataSource As CurrencyManager, _
ByVal RowNum As Integer) As Boolean
HideLinkLabel()
If Not InEdit Then
Return True
End If
Try
Dim Value As Object = dgLinkLabel.Text
If NullText.Equals(Value) Then
Value = Convert.DBNull
End If
SetColumnValueAtRow(DataSource, RowNum, Value)
Catch e As Exception
RollBack()
Return False
End Try
EndEdit()
Return True
End Function
'
' Remove focus
'
Protected Overloads Overrides Sub ConcedeFocus()
dgLinkLabel.Visible = False
End Sub
'
' Edit Grid
'
Protected Overloads Overrides Sub Edit(ByVal Source As CurrencyManager, _
ByVal Rownum As Integer, _
ByVal Bounds As Rectangle, _
ByVal [ReadOnly] As Boolean, _
ByVal InstantText As String, _
ByVal CellIsVisible As Boolean)
dgLinkLabel.Text = String.Empty
Dim OriginalBounds As Rectangle = Bounds
OldVal = dgLinkLabel.Text
If CellIsVisible Then
Bounds.Offset(xMargin, yMargin)
Bounds.Width -= xMargin * 2
Bounds.Height -= yMargin
dgLinkLabel.Bounds = Bounds
dgLinkLabel.Visible = True
Else
dgLinkLabel.Bounds = OriginalBounds
dgLinkLabel.Visible = False
End If
dgLinkLabel.Text = GetText(GetColumnValueAtRow(Source, Rownum))
If Not InstantText Is Nothing Then
dgLinkLabel.Text = InstantText
End If
dgLinkLabel.RightToLeft = Me.DataGridTableStyle.DataGrid.RightToLeft
dgLinkLabel.Focus()
If InstantText Is Nothing Then
dgLinkLabel.Select()
Else
Dim [End] As Integer = dgLinkLabel.Text.Length
dgLinkLabel.Select()
End If
If dgLinkLabel.Visible Then
DataGridTableStyle.DataGrid.Invalidate(OriginalBounds)
End If
InEdit = True
End Sub
Protected Overloads Overrides Function GetMinimumHeight() As Integer
'
' Set the minimum height to the height of the linklabel
'
Return dgLinkLabel.PreferredHeight + yMargin
End Function
Protected Overloads Overrides Function GetPreferredHeight(ByVal g As Graphics, _
ByVal Value As Object) As Integer
Debug.WriteLine("GetPreferredHeight()")
Dim NewLineIndex As Integer = 0
Dim NewLines As Integer = 0
Dim ValueString As String = Me.GetText(Value)
Do
While NewLineIndex <> -1
NewLineIndex = ValueString.IndexOf("r\n", NewLineIndex + 1)
NewLines += 1
End While
Loop
Return FontHeight * NewLines + yMargin
End Function
Protected Overloads Overrides Function GetPreferredSize(ByVal g As Graphics, _
ByVal Value As Object) As Size
Dim Extents As Size = Size.Ceiling(g.MeasureString(GetText(Value), _
Me.DataGridTableStyle.DataGrid.Font))
Extents.Width += xMargin * 2 + DataGridTableGridLineWidth
Extents.Height += yMargin
Return Extents
End Function
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, _
ByVal Bounds As Rectangle, _
ByVal Source As CurrencyManager, _
ByVal RowNum As Integer)
Paint(g, Bounds, Source, RowNum, False)
End Sub
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, _
ByVal Bounds As Rectangle, _
ByVal Source As CurrencyManager, _
ByVal RowNum As Integer, _
ByVal AlignToRight As Boolean)
Dim Text As String = GetText(GetColumnValueAtRow(Source, RowNum))
PaintText(g, Bounds, Text, AlignToRight)
End Sub
Protected Overloads Sub Paint(ByVal g As Graphics, _
ByVal Bounds As Rectangle, _
ByVal Source As CurrencyManager, _
ByVal RowNum As Integer, _
ByVal BackBrush As Brush, _
ByVal ForeBrush As Brush, _
ByVal AlignToRight As Boolean)
Dim Text As String = GetText(GetColumnValueAtRow(Source, RowNum))
PaintText(g, Bounds, Text, BackBrush, ForeBrush, AlignToRight)
End Sub
Protected Overloads Overrides Sub SetDataGridInColumn(ByVal Value As DataGrid)
MyBase.SetDataGridInColumn(Value)
If Not (dgLinkLabel.Parent Is Value) Then
If Not (dgLinkLabel.Parent Is Nothing) Then
dgLinkLabel.Parent.Controls.Remove(dgLinkLabel)
End If
End If
If Not (Value Is Nothing) Then Value.Controls.Add(dgLinkLabel)
End Sub
Protected Overloads Overrides Sub UpdateUI(ByVal Source As CurrencyManager, _
ByVal RowNum As Integer, ByVal InstantText As String)
dgLinkLabel.Text = GetText(GetColumnValueAtRow(Source, RowNum))
If Not (InstantText Is Nothing) Then
dgLinkLabel.Text = InstantText
End If
End Sub
'----------------------------------------------------------------------
' Helper Methods
'----------------------------------------------------------------------
Private ReadOnly Property DataGridTableGridLineWidth() As Integer
Get
If Me.DataGridTableStyle.GridLineStyle = DataGridLineStyle.Solid Then
Return 1
Else
Return 0
End If
End Get
End Property
Private Sub EndEdit()
InEdit = False
Invalidate()
End Sub
Private Function GetText(ByVal Value As Object) As String
If Value Is System.DBNull.Value Then Return NullText
If Not Value Is Nothing Then
Return Value.ToString
Else
Return String.Empty
End If
End Function
Private Sub HideLinkLabel()
If dgLinkLabel.Focused Then
Me.DataGridTableStyle.DataGrid.Focus()
End If
dgLinkLabel.Visible = False
End Sub
Private Sub RollBack()
dgLinkLabel.Text = OldVal
End Sub
Private Sub PaintText(ByVal g As Graphics, _
ByVal Bounds As Rectangle, _
ByVal Text As String, _
ByVal AlignToRight As Boolean)
Dim BackBrush As Brush = New SolidBrush(Me.DataGridTableStyle.BackColor)
Dim ForeBrush As Brush = New SolidBrush(Me.DataGridTableStyle.ForeColor)
PaintText(g, Bounds, Text, BackBrush, ForeBrush, AlignToRight)
End Sub
Private Sub PaintText(ByVal g As Graphics, _
ByVal TextBounds As Rectangle, _
ByVal Text As String, _
ByVal BackBrush As Brush, _
ByVal ForeBrush As Brush, _
ByVal AlignToRight As Boolean)
Dim Rect As Rectangle = TextBounds
Dim RectF As RectangleF = RectF.op_Implicit(Rect) ' Convert to RectangleF
Dim Format As StringFormat = New StringFormat()
If AlignToRight Then
Format.FormatFlags = StringFormatFlags.DirectionRightToLeft
End If
Select Case Me.Alignment
Case Is = HorizontalAlignment.Left
Format.Alignment = StringAlignment.Near
Case Is = HorizontalAlignment.Right
Format.Alignment = StringAlignment.Far
Case Is = HorizontalAlignment.Center
Format.Alignment = StringAlignment.Center
End Select
Format.FormatFlags = Format.FormatFlags Or StringFormatFlags.NoWrap
g.FillRectangle(Brush:=BackBrush, Rect:=Rect)
Rect.Offset(0, yMargin)
Rect.Height -= yMargin
g.DrawString(Text, Me.DataGridTableStyle.DataGrid.Font, ForeBrush, RectF, Format)
Format.Dispose()
End Sub
End Class
|
|
|
|
|
Hi all:
I Have 2 controls in Form1 (TextBox1 and Command1).
TextBox1.Text = "111"
Then I have a class (myClass.vb) that inherits Form1
This class as a:
Sub ChangeText()
dim objForm1 as New Form1
objForm1.TextBox1.Text = "222"
End Text
When I click on Command1 i want to go to the ChangeText() in the other class and change TextBox1.Text
Sub Command1_OnClick
dim objmyClass as New myClass
objmyClass.ChangeText()
End Sub
But it doesn't work
How can I change TextBox1 properties or other Control properties that are in Form1.vb from a sub that is in myClass.vb?
Thanx in advance.
Bruno
|
|
|
|
|
Getting value from stuff you don't own is a compelling
idea. Just think, someone else has created something
that has value, and has made it available to you. You
can now leverage its value in ways that makes all
parties richer. That's the promise of web services.
You need to know about web services. The advent of
standards-based web services marks a new era of
system development. First mainframe, then client-server,
the Web, now web services makes it possible to leverage
every legacy system of the past and do so much more
with your information assets.
Architag Press, a division of Architag International
Corporation, announces the publication of Web Services
Implementation Guide, Volume 1: Getting Started, by
Brian E. Travis and Mae Ozkan.
Sample chapters of the book is available at
http://www.architag.com/press/wsig.
This book will show you what a web service is, and
how you can align your internal systems and external
trading partner interactions to take advantage of this
new concept in system integration.
You will learn about the "Three Steps to Web Services":
* Automate internal systems
* Determine integration points
* Expose integration points as web services
This book is for systems architects, developers,
and I.T. decision makers.
Highlights in this book:
* Written in a light, entertaining style.
* Emphasis on architectural design for web services.
* A tutorial on the state of web services standards.
* Plenty of real-life examples of web service use.
* Tutorials on the key technologies: XML, SOAP,
WSDL and UDDI.
* Code samples of key XML-based web services
technologies and extensions.
* Companion Web site with all code samples and
late-breaking information.
----
Download sample chapters of Web Services Implementation
Guide at http://www.architag.com/press/wsig/.
Stanford Powers, Publisher Architag International Corp
Phone: 866-898-0001 Outside US: +1-303-426-3126
Email: spowers@architag.com Fax: 720-294-1396
|
|
|
|
|
Stanford Suck... Berkeley Kick A~~
|
|
|
|
|
Okay, I have an mdi application that I want to close (by pressing the go away button) it has one child form open, which contains dirty data. Due to the nature of "WetWare" (users) issues I display a dialog that says "You have dirty data did you really mean to save it, or would you like to abandon your changes?" This is done in the queryUnload of the mdi child. If the user choose to saves we get stuck in an infinate queryunload event loop.
Private Sub Form_QueryUnload(cancel As Integer, _
UnloadMode As Integer)
writelog "Query Unload"
Debug.Print "hwnd:= " & Me.hwnd
cancel = Not (CheckSave())
end sub
Private Function CheckSave() As Boolean
''False I was unable to save something,
''or the user canceled
''true life is good. I am successful and or compleate
if not dirty then
... New form
... show form
<user get="" their="" opinion="" here="">
... unload form
... set form = nothing
end if
end function
Am I missing something or should this work? What kind of restrictions is there in the queryUnload event. None of the ms documentation mentioned that form creation is a bad idea
Any sugesstions would be appricated .
|
|
|
|
|
Ouch! This really belongs in the VB forum.
Please post it over there with all of the code from your QueryUnload proc.
--
I hate to pull the WRONG BOARD thing, but hey its for the cause.
|
|
|
|
|
Check at at wich kind of UnloadMode you wan't to prompt the user and only then set cancel to one '1'.
Private Sub Form_QueryUnload(cancel As Integer, _ <br />
UnloadMode As Integer)<br />
writelog "Query Unload"<br />
Debug.Print "hwnd:= " & Me.hwnd<br />
If CheckSave()) Then cancel = 1 '<<<<br />
end sub
Should do
|
|
|
|
|
|
Hey Roger, I'm awake, but he has already been warned to move his question. Did you find you answer Jason?
Nick Parker
|
|
|
|
|
Sorry, I didn't post sooner .... I could not find my message I was not aware there was a vb section.
I tried the different code:
...If CheckSave() Then Cancel = 1
But no, that has the exact same effect as the original code
it seems like the community thinks this should be an okay use of a form and a dialog, so I must be creating a referance or something that is messing me up... I am still looking into it
Thanks for your time, All.
|
|
|
|
|
i want to put a browse like button which would actually let me browse through the computer and entire network for files to determine the path of files or folders.
Plz tell me how do i add this browsing facility to a VB 6.0 form.
thanks
waiting for a quick reply
|
|
|
|
|
add a comman Dialog active x control to your form.
1) add the component
project-> components -> then place a check box next do comman dialog controls.
2) place the control on your form.
3)and then use code like below
ComDialogfrmMain.CancelError = True
ComDialogfrmMain.Flags = cdlOFNNoValidate
' Set filters
ComDialogfrmMain.Filter = "All Files (*.*)|*.*|Text Files" & _
"(*.txt)|*.txt|Data Files (*.Dat)|*.Dat"
' Specify default filter
ComDialogfrmMain.FilterIndex = 3
' show dialog
ComDialogfrmMain.ShowOpen
xtFileName = ComDialogfrmMain.FileName
|
|
|
|
|
i want to put a browse like button which would actuallt let me browse through the computer and entire network for files to determine the path of files or folders.
Plz tell me how do i add this browsing facility to a VB 6.0 form.
thanks
waiting for a quick reply
|
|
|
|
|
Hi experts,
I have a problem about the MSComm work with RS485 serial port communication.
The problem is that I can't detect the end of output to change the flag "DTREnable" from False to True.
I have tried the OnComm event "comEvSend" by set the SThreshold=1, the DTREnable flag can't remain False until the end of the output. Also the OutBufferCount value always zero.
Please suggest the work method, thx
Jolly
|
|
|
|
|
I have the following simple code, yet in the finally block the compilier says that "'con' is not declared." What's up with this?
(LogEvent is just an event log wrapper function which works like a champ.)
<br />
Try <br />
Dim con As New SqlConnection(Configuration.Settings("ConnectionString")) <br />
Dim cmd As New SqlCommand("INSERT INTO Messages (MessageType, Message) VALUES('" & _ <br />
MessageType & "','" & Message & "')", con) <br />
<br />
cmd.ExecuteNonQuery() <br />
Catch e As Exception <br />
LogEvent(e.ToString(), EventLogEntryType.Error) <br />
Finally <br />
con.Close() '<- compiler error here: "con" is not declared. <br />
End Try <br />
-John
|
|
|
|
|
con needs to have been declared outside of the try block, as thus:
<br />
Dim con As SqlConnection <br />
Dim cmd As SqlCommand <br />
<br />
Try <br />
con = New SqlConnection(Configuration.Settings("ConnectionString")) <br />
cmd = New SqlCommand("INSERT INTO Messages (MessageType, Message) VALUES('" & _ <br />
MessageType & "','" & Message & "')", con) <br />
<br />
cmd.ExecuteNonQuery() <br />
Catch e As Exception <br />
LogEvent(e.ToString(), EventLogEntryType.Error) <br />
Finally <br />
con.Close() <br />
End Try <br />
-John
|
|
|
|
|
Is it possible?
How can I trace through my DLL Code from VB? or hell, how do you debug a VC++ DLL normally ?
Ryan Baillargeon
Software Specialist
Fuel Cell Technologies Inc.
|
|
|
|
|