|
can every 1 give example?
im currently doin some study..is it possible store data using note pad?
data tat 1 wanna store(example)
i.d, name, .jpeg(picture file)
any resource, pls reply me....thanks!!!!
|
|
|
|
|
williamccyccyccy wrote: is it possible store data using note pad?
Yes, you type your data into a TextBox (this is all Notepad is really) and Notepad will let you save it to a .TXT file. Is it practical? Nope.
Can your application save data to a .TXT file? Yes. Can you save an image in a .TXT file? No, but you can save the path to an image file.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Use the code below to create and write to a text file
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
oWrite = oFile.CreateText(Path\filename.txt)
Dim fileStream As FileStream
Dim streamWriter As StreamWriter
fileStream = New FileStream(Path:=path\filename.txt", mode:=FileMode.Append, access:=FileAccess.Write)
streamWriter = New StreamWriter(Stream:=fileStream)
streamWriter.BaseStream.Seek(offset:=0, origin:=SeekOrigin.End)
streamWriter.WriteLine(value:="" & field1 & field2 & "")
streamWriter.Flush()
streamWriter.Close()
fileStream.Close()
Hope this code is helpful to u. However, you will not be able to store images in the text file.
With Best Regards,
Mayur
|
|
|
|
|
You might want to check to make sure your replying to the correct post...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
Another question for all you DataGrid gurus out there... I have a read only datagrid which (for reasons that are unimportant here) my users want to totally ignore any mouse clicks. However, the grid will always need to be scrolled so I can't simply set the grid 'Enabled' property to False.
What I really want is something like what you can do with the KeyPress/KeyDown events where you can say '<event args="" object="">.Handled = true' and the event will simply ignore that key... how can I do the same *just* for my datagrid but for mouse clicks?
TIA once again for any help.
Mike
|
|
|
|
|
What specifically is it you want to ignore? Column sorting? If so, set AllowSorting to False. Colors changing when a row is clicked? If so, set the SelectionBackColor to be the same as BackgroundColor. You would also probably want to set RowHeadersVisible to False and ReadOnly to True. Is there something beyond this?
Dean
|
|
|
|
|
Thanks Dean... the issue we're having is even when the datagrid is readonly the user can still click on the grid and the selected cell changes colours as if it is going to allow the user to edit it... I'll try the SelectionBackColor and see how that goes.
Even so I do wish there was a way to ignore (or turn off) a certain event for any control like the handled property of KeyDown does.
Mike
|
|
|
|
|
|
|
Email will not send my visual studio 2003 project
1. I am using MSDE, IIS, Visual studio 2003, 1.1 netframework, I have mail Outlook and msn homail,
2. these are installed on windows xp
3. Can I send email if I only have msde and not a regular server?
4. The project works except the sending of the email
5. I thought I have coded below correctly, but I do not receive emails
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application is started
'1. Create a connection
Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
myConnection.Open()
'2. Create the command object, for the query
Const strSQL As String = "Select LastUpdated, ProductId from products "
Dim objCmd As New SqlCommand(strSQL, myConnection)
Dim objDR As SqlDataReader
Dim att
objDR = objCmd.ExecuteReader()
While (objDR.Read)
If (Not (objDR("LastUpdated") Is DBNull.Value)) Then
If (Date.Compare(objDR("LastUpdated"), Today.Date) = 0) Then
Dim newMail As New MailMessage
newMail.From = "from@from.com" '' this is the From Address
newMail.To = "kenn_rosie@msn.com" '' this is TO Address
'newMail.Cc = "hadeedian@hotmail.com" '' this is TO Address
newMail.Subject = "Change in Product Rate"
newMail.Body = " Dear Ken, " & "Please review attached email for product ID: " & objDR("ProductID") & "Thank you," & "Kenn()"
att = New MailAttachment("C:\Inetpub\wwwroot\GrocerToGo\Product_Changed.doc")
newMail.Attachments.Add(att)
newMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
newMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username")
newMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password")
SmtpMail.SmtpServer = "mailserver"
SmtpMail.Send(newMail)
End If
End If
End While
myConnection.Close() 'Close the connection
End Sub
|
|
|
|
|
A few things to check...
Try to sent an email from the command line via telnet, this is email in it's simplest form to comfirm that port 25 and the SMTP server are OK.
http://www.yuki-onna.co.uk/email/smtp.html[^]
If this works great if not check you don't have port filtering or antivirus stopping your mail app. McAfee has a "unwanted apps filter" as some of the others do and this treats port 25 bound apps as mail worms, (This caught me out on my app).
Hope this helps, let me know...
P.S. Code looks OK will try it and see.
When people make you see red, be thankful your not colour blind.
-- modified at 19:45 Wednesday 22nd February, 2006
|
|
|
|
|
OK Tested the email portion of your code...
Imports System.Web.mail
<br />
Dim newMail As New MailMessage<br />
Dim SmtpSvr As SmtpMail<br />
<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
<br />
End Sub<br />
Private Sub mySendMail()<br />
<br />
SmtpMail.SmtpServer = "127.0.0.1"<br />
newMail.To = "kne@canon.com.au" '' this is TO Address<br />
newMail.From = "japel-xp@localhost" '' this is the From Address<br />
newMail.Subject = "Change in Product Rate"<br />
newMail.Body = "Dear Ken"<br />
SmtpMail.Send(newMail)<br />
<br />
End Sub<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
mySendMail()<br />
End Sub<br />
Added the (Dim SmtpSvr As SmtpMail) and the rest worked. Please let me know how you go...
Also catch the email Exception by putting your code in a try/catch the below will tell you the return smtp server error e.g. 550 No Realy...
<br />
Catch ex As Exception<br />
MessageBox.Show(ex.GetBaseException.Message)<br />
End Try<br />
When people make you see red, be thankful your not colour blind.
|
|
|
|
|
hellow to all..
i am looking for a piece of code that can help me accessing crystal sections and change text by code ..
any ideas ?
thxx
|
|
|
|
|
How can I make a modeless form notify its parent that it has closed?
Thanks
-mE
|
|
|
|
|
Your parent form should catch the modeless form's Closed event.
Parent Form Code:
Public Class ParentForm : Inherits System.Windows.Forms.Form
'
' Keep a member variable of modeless form. Use WithEvents.
Private WithEvents myModelessForm As New ModelessForm
'
' Show the modeless form.
Private Sub ParentForm_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
myModelessForm.Show()
End Sub
'
' Catch the modeless form's Closed event.
Private Sub myModelessForm_Closed(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles myModelessForm.Closed
MessageBox.Show("Modeless form was closed!")
End Sub
End Class
|
|
|
|
|
This worked nicely.
Many Thanks
-mE
|
|
|
|
|
I am writing an application in VB .NET using Visual Studio 2005. I think the menu strip is awesome. However, is there a way to have the menu/toolbars have an Office XP appearance that highlights blue when blue is selected as the system color on Windows XP, olive when XP's theme is Olive green, etc...?
Thanks for your time.
|
|
|
|
|
This may help...
Public Shared Sub Main()<br />
<br />
' Display your main form with XP theme.<br />
Application.EnableVisualStyles()<br />
Application.DoEvents()<br />
Application.Run(New Form1)<br />
End Sub
Set the Button's FlatStyle Property to 'System'
Hope it helps - Richard
|
|
|
|
|
Hello,
We have a need to schedule a task in windows scheduler. For that i need to generate an .exe file of the application i am working on. So as a first step, I got the code snippet working in my Windows Application(was done using VB.net 2005). But this code fires up with a button click event. I also added an Application Configuration File to throw few variales. And this works exactly as i needed.
Now, i put the above code snippet in Main() method of the windows form and built it. I got the .exe under my debug goder. When i double click on it i got the windows form popped up. And at the same time it also performed the job i wanted to(as i have my code under the Main() method). But i don't want the UI(windows form) to be popped up. My objective is run ever thing under hood with no user interface. In other words i am expecting some thing like when we run a .bat file it does the job with no user interface. I need some thing in the similar fashion.
For that do i need to create a Windows Console application and paste my code and build it? I also tried with the Console application and it does exactly what i was expecting for. But i am just curious and want to know can't we use the Windows Application type project and then hide the Windows form to hid when we double click on the .exe file?
Please help me understand what type of application, either Windows Application type or Console Application type project works best in my scenario.
Thanks
-L
|
|
|
|
|
If you use a Console App, then the console window will automatically come up when your app is ran, which is not what you want.
Instead, I think you should do this in a WinForm application without any forms. You will need to set the Startup Object to "Sub Main". You should put your Sub Main within its own class, say "Class Main".
-- modified at 18:48 Wednesday 22nd February, 2006
|
|
|
|
|
Is there a way to adjust the contents to a DataGridView to match what a user has typed in a textbox. As the user types in or removes a character from the text box, the DataGridView contents will adjust accordingly from the intial data populating the control from a Datatable. I would prefer to avoid loops, if at all possible. I would be willing to use a ListView control. I also tried to look for a method in a DataSet or DataTable and populate a second DataTable to bind to the grid, but could find a way. Any ideas?
Thank You
|
|
|
|
|
Not sure if I understand your question entirely, but you could try this:
Dim dt as New Datatable
'
'Code to fill your table
'
dim dv as new dataview(dt)
Datagrid1.datasource = dv
'Then in the Textbox TextChanged Event, you can modify the filter value
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
' "Name" is a column name in your datatable
dv.RowFilter = "Name LIKE ' " & Me.Textbox1.Text & " * ' "
'This will filter for anything that begins with whatever is typed in the textbox
End Sub
|
|
|
|
|
Thanks. Your code did exactly what I needed to do. I tweaked it somewhat. Here it is.
Private Sub txtSysName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSysName.TextChanged
'if nothing in textbox, display all rows
If Me.txtSysName.Text.Trim.Length = 0 Then
DataGridView1.DataSource = ds.Tables(0)
Msg.Text = "System count: " & DataGridView1.Rows.Count
Exit Sub
End If
'create dataview and populate with dataset populated in form load
Dim dv As New DataView(ds.Tables(0))
With dv
.Table = ds.Tables(0)
'.AllowDelete = True
'.AllowEdit = True
'.AllowNew = True
.RowFilter = "vchrName LIKE '" & Me.txtSysName.Text & "*'"
.RowStateFilter = DataViewRowState.CurrentRows
.Sort = "vchrName ASC"
End With
'reset grid datasource to contents of new dataview
DataGridView1.DataSource = dv
'display row count
Msg.Text = "System count: " & DataGridView1.Rows.Count
End Sub
|
|
|
|
|
Hey,
I'm a beginner in VB.NET and I'm trying to build a small application. In this application I create an object (user) on Form1 (IMSLogin). In my second form, I want to keep using the same object.
I tried to do this by coding the following:
IMSLogin is the form where the user-object is created.
<br />
Public Class IMSLogin<br />
Inherits System.Windows.Forms.Form<br />
Private frmMainMenu As MainMenu<br />
Public user As New User<br />
Me.frmMainMenu = New MainMenu(user)<br />
Me.frmMainMenu.Show()
MainMenu is the form where I want to use the user-object that was passed by via IMSLogin. This is my coding for MainMenu:
Public Class MainMenu<br />
Inherits System.Windows.Forms.Form<br />
<br />
Dim user As User<br />
<br />
Public Sub New(ByVal objUser As User)<br />
MyBase.New()<br />
<br />
'This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
<br />
Dim UserFromParent As User<br />
UserFromParent = objUser<br />
End Sub<br />
End Class
When I try to build my application, I get the following error:
"MainMenu" is a type in "WindowsApplication1" and cannot be used as an expression.
Can someone please help me with this? It's really urgent!
Thanks!!!!!!
G72360
|
|
|
|
|
I see 2 issues here...
1)
Me.frmMainMenu = New MainMenu(user)<br />
Me.frmMainMenu.Show()
The above code needs to be executed inside of a method. You should put it in the Form's load event handler, like this...
Private Sub IMSLogin_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Me.frmMainMenu = New MainMenu(user)
Me.frmMainMenu.Show()
End Sub
2)
In MainMenu's constructor, you didn't assign the objUser parameter to MainMenu's member variable. You assigned it to a local variable instead, which will be lost as soon as it goes out of scope in the constructor.
You should do this instead...
Private user As User
'
Public Sub New(ByVal objUser As User)
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'
user = objUser
End Sub
I also have a couple nit-picky suggestions to make too.
1) You should avoid creating local/member variables having the same name as their type, like you did here.
Private user As User
Instead, call it something like "currentUser" or "loginUser" or whatever. It looks like you were doing a little hungarian notation here, so you could follow suit and call it "m_user" too.
2) You should post fix "Form" to the end of your Form class names. That makes it clear what they are and it'll follow Microsoft's naming guidelines. I think this is especially important for your MainMenu form class, which can easily be confused as a control.
|
|
|
|