|
Hi all,
I have a data sheet from rtf file that I read into the excel table so that it looks need. I also have a limit as to the range of these values. Eg. 3 to 7. So if the value in the cell is 9, it is out of range and I am suppose to highlight it in red colour. Any help on this ? I am using Visual Basic, not VBA.
On another question, is there any good Visual Basic example of how to draw a chart without having the program crash during the second time? Thanks in advance.
|
|
|
|
|
I want to return a value from textbox to other form when it opens, how to code the return?
my code:
In FORM1:
file_location = textbox1.text
Private Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click
Dim view As New frmView
MessageBox.Show(file_location)
If view.ShowDialog() = DialogResult.OK Then
End If
End Sub
Public Property ReturnView() As String
Get
Return file_location
End Get
Set(ByVal Value As String)
file_location = Value
End Set
End Property
In FORM2:
Dim AddJob As New frmAddJob
view = AddJob.ReturnView
TextBox1.Text = view
The problem is the view is nothing..it can't pass the value to form2..
does everybody know what's wrong with code? Thanks for your help..
-----------------------Lisa--------------------------
|
|
|
|
|
If I'm reading this correctly you want to click on a button on form1 which contains a textbox and pass the contents of the textbox to Form2.
Simply set up a module with a variable mvarfile_Location as string. When you click on the button. Set this public/friend module level variable and show form2. In the form2 load event - retrieve the contents of this module level variable mvarfile_Location .
FORM1
*****
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Frm2 As New Form2
mvarFileLocation = TextBox1.Text
MessageBox.Show(mvarFileLocation )
If view.ShowDialog() = DialogResult.OK Then
End If
End Sub
FORM2
*****
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
me.text = mvarFileLocation
End Sub
End Class
Module test
Public mvarFileLocation As String
End Module
Of course you could use a class and properties etc. But basically you are putting the contents into a variable/property etc. accessible from both forms.
Alternatively
You could pass a reference to form2 from form1 and use this to directly access form1.
|
|
|
|
|
Thank you very much! It works perfect!
Lisa
|
|
|
|
|
Hi all..
can i work on a unified screen resolution in order for the views to appear the same. Is there a way to make the views and fonts dynamically adjustable according to the screen resolution in vb.net?
Thanks alot
|
|
|
|
|
I am trying to iterate through a hashtable using an enumerator. I want to change some values as I go.
Here is a simplified version of my code….
ptr = hashTab.GetEnumerator<br />
<br />
While ptr.MoveNext<br />
hashTab.Item(ptr.Key) = "something different"<br />
End While
I get the following exception when I change a value – Collection was modified; enumeration operation may not execute.
What is the correct way to perform this type of operation?
John.
|
|
|
|
|
The problem occurs because you are completely replacing the item in the hashtable. This is not allowed during an enumeration.
If your hashtable contains objects, it is allowed to update properties of those objects. So one solution is to create an object (or type) that contains the string value.
Another solution is to build a new collection, and then discard the old one.
my blog
|
|
|
|
|
Hashtable belongs to readonly dictionary base object. Thu editing the content is not possible.what you can do ir remove the key and add it again with the new value:
hashTab.Remove ptr.Key
then...
hashTab.Add ptr.Key, “something different”
|
|
|
|
|
I'm trying to save a MS Word shape of the type msoDiagram into a separate file and to this end I thought if I could convert the diagram into an image , then I could easily save the image into a file. However I'm unable to figure out a way to convert the diagram into an image - anybody has any idea ?
Smriti
|
|
|
|
|
if you are using MS Office 2003 you can print your document to MS Office Image writer, this will create a YourDocument.mdi file for you after you open it (by double clicking it) you can use the Save as... to save your file as image (YourDocument.tif)
Hope this will help
xiao xiao
|
|
|
|
|
This is my datagrid table:
Entity_id customer phone address
1 name 222
2 name2 333
3 name3 444
button: show entity_id
when you select which row, then that row's entity_id pass to the button, when you click the button, then popup messagebox to tell you what entity_id you select..
is everybody has any idea to do this function?
- Lisa
|
|
|
|
|
Perhaps this is what you are looking for....
Get the current cell's rownumber
and then build string for the messagebox which looks at the appropriate columns on that cell.....
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strTest As String
Dim iRowNumber As Integer
Try
iRowNumber = DataGrid1.CurrentCell.RowNumber()
strTest = "Selected Identify " & CStr(DataGrid1.Item(iRowNumber, 1))
MessageBox.Show(strTest)
Catch ex As Exception
End Try
End Sub
SkyTribe
|
|
|
|
|
thanks SkyTribe..
But that is not I'm dealing with in my appl. I need the entityID whick is clicked to forward to another form to the next SQL: select * from customer where entity_id = entityID...
Lisa
|
|
|
|
|
Then how about this....
Public Class MainForm
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm3 As New Form3
With frm3
.ID = TextBox1.Text
.Show()
End With
End Sub
End Class
and a sub form containing a single label control.
Public Class Form3
Inherits System.Windows.Forms.Form
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strTest As String
strTest = "Item Selected = " & mvarID
Label1.Text = strTest
End Sub
Private mvarID As String
Public Property ID() As String
Get
Return mvarID
End Get
Set(ByVal Value As String)
mvarID = Value
End Set
End Property
End Class
With this the contents of textbox (but it could be any items on the mainform are used to set properties on the sub form (frm3) which are then used in frm3.
In this case there is a single label called label1 on the sub form which is set from the contents of the textbox on mainform.
If you wanted to pass a integer then simply change the property to integer. If you wanted to pass a series of integer for say a SQL select statement then you could construct a where clause sting on the main and pass a single string or pass a collection or data structure of integer values to the sub form to be parsed into a sql string.
|
|
|
|
|
This is my code..
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objConn As String = "Provider=SQLOLEDB;Data Source=server;"
Dim objString As String = "SELECT entity_id, client_number, client_name FROM Companies WHERE status=1"
Dim DA As OleDbDataAdapter
Dim DS As DataSet
Dim conn As New OleDbConnection(objConn)
DA = New OleDbDataAdapter(objString, objConn)
DS = New DataSet
DA.Fill(DS, "Companies")
conn.Close()
DataGrid1.DataSource = DS.Tables("Companies")
'how to get the entity_id when user select client_number row? how to sign the entity = ??
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'messagebox test if pass the right entity_id
MessageBox.Show(entity)
dim form2 as new form2
form2.showdialog()
End Sub
Public Class Form2
Inherits System.Windows.Forms.Form
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objConn As String = "Provider=SQLOLEDB;Data Source=server;"
Dim objString As String = "SELECT client_number, client_name, contact, phone_number, address, city FROM Companies WHERE status=1 and entity_id = " & entity
Dim DA As OleDbDataAdapter
Dim DS As DataSet
Dim conn As New OleDbConnection(objConn)
DA = New OleDbDataAdapter(objString, objConn)
DS = New DataSet
DA.Fill(DS, "Companies")
conn.Close()
DataGrid1.DataSource = DS.Tables("Companies")
End Sub
Lisa
|
|
|
|
|
With Option Strict On...How do I get a date from a textbox to a variable defined as date?
|
|
|
|
|
myDate = DateTime.Parse(myTextBox.Value)
my blog
|
|
|
|
|
Generaly when the option stict on is set you can convert value's on two way's
1- use the ctype like
Dim MyDate as Date
MyDate = cType(me.textBox1.text, Date)
2- Using the Cast method.
I must check some things how that is working I never needed yet.
I respond on this later.
|
|
|
|
|
Hi everyone
I need help about how can I integrate 2 project. I have one project doing one thing (reports issues) and the other project doing other thing (security managements).
Right now this 2 project running well but independend, I want to modify the second project for calling any project i want. but in don't know how do that..
Please help me on that..
Johnny Lizardo
|
|
|
|
|
jlizardo wrote:
I want to modify the second project for calling any project i want.
This would seem to contradict your requirement of integrating the two projects into one. Since you have the Security functionality encapsulated into a single a project, you would normally keep it that way. If you wanted to use it in a seperate SOLUTION, not a project, you would simply add a project reference to the Security project.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi there,
Who can help me on this one.
I have a table with some columns. One of these columns contains richtext text.
I want to show this table on something like a data grid or flex grid.
I get the data but the The richt text column shows only the raw data.
I now I must reconfiger the data column but how ?
any idea
|
|
|
|
|
'One way to add a RichtextBox to a DataGrid Column
'just in case you wanna try it.
Public WithEvents cRtb As New RichTextBox
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cellBounds As New System.Drawing.Rectangle 'cell bounds
'
' Setup your DataGrid Code Here First!!!
' If your datagrid has no columns this method won't work.
'
' Then add the Richtextbox to column 2
'
cellBounds = DataGrid1.GetCellBounds(DataGrid1.CurrentRowIndex, 2)
cRtb.Location = New Point(cellBounds.X, cellBounds.Y)
cRtb.Size = New Size(cellBounds.Width, cellBounds.Height)
cRtb.BorderStyle = BorderStyle.None
cRtb.Text = "Here is the RTB"
DataGrid1.Controls.Add(cRtb)
cRtb.BringToFront()
cRtb.Show()
End sub
' to make sure it follows the scrollbars around
Private Sub DataGrid1_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Scroll
Dim cellBounds As New System.Drawing.Rectangle 'cell bounds
cellBounds = DataGrid1.GetCellBounds(DataGrid1.CurrentRowIndex, 2)
cRtb.Location = New Point(cellBounds.X, cellBounds.Y)
cRtb.Size = New Size(cellBounds.Width, cellBounds.Height)
End Sub
|
|
|
|
|
Nice
But I get the Richtext box on only one cell at the time (the current selected row).
I placed the code from the Load event to the DataGrid_DataSourceChange event and looped the code
for every row in the grid.
Private Sub HistoryGrid_DataSourceChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles HistoryGrid.DataSourceChanged
Dim cellBounds As System.Drawing.Rectangle
Dim I As Integer = 0
Do
cellBounds = New System.Drawing.Rectangle() 'cell bounds
cellBounds = Me.HistoryGrid.GetCellBounds(I, 9)
cRtb.Location = New Point(cellBounds.X, cellBounds.Y)
cRtb.Size = New Size(cellBounds.Width, cellBounds.Height)
cRtb.BorderStyle = BorderStyle.None
If Not IsDBNull(Me.HistoryGrid.Item(I, 9)) Then
cRtb.Rtf = CType(Me.HistoryGrid.Item(I, 9), String)
end If
Me.HistoryGrid.Controls.Add(cRtb)
cRtb.BringToFront()
cRtb.Show()
Loop Until I = Me.HistoryGrid.VisibleRowCount
End Sub
How can I display the richtext box on every cell in the column 9
any idea here
Thanks.
|
|
|
|
|
RDoes,
I'm not sure you would want to do that,
If you had 100 rows that would create 100
RTB's and that would be a bad thing all around.
Let me think on it for awhile, maybe I can find a different way.
ProgLoad
|
|
|
|
|
Progload,
Yes you right.
Maybe something with a component class. I have seen some examples with a button or picture but I
Doesn't understand how it works (I mean the concept of it)
But if that is using also a lot of resources I can beter create a form with some like a master detail
structure ?
rdoes
|
|
|
|