|
I have two forms, and what I want is to save the data in both forms to an excel spreadsheet. I want the information in form 1 to appear first, and the information in form 2 to appear after form 1.
e.g. this is the form:
I want the excel spreadsheet to appear like this:
and I want the information on the second form, form 2 to appear on cells J, K, L, M etc... after the first form 1 information.
I have a button that says "Save to spreadsheet" on form 2 and I want to save a spreadsheet with the information in the rext boxes on form 1 and 2 like I showed. Any ideas? I am using VB 2005
In the end we're all just the same
|
|
|
|
|
You can use the Office Interop Library to create the excel spreadsheet.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I have a text box on my form called "txtIntrest" and I want it to display the first line in a text file called "Intrest.txt". I also want that, if you change the text in the "txtIntrest", it will ask you for a password and you have to type one in and this changes the information in the text file. If you press cancel on the password screen, it reverts back to what was in text box originally.
Any ideas?
In the end we're all just the same
|
|
|
|
|
Hello Dave,
You can try using the following code implementation. In this I have taken a textbox and a button.
On form load, textbox automatically fills with the first line of the file. On button click, it
will check the text box for any changes and then it will do what you require. It will ask for
password and after verifying the password, make the changes back to the file. password is coded
right now. You can use various techniques to read it from a file.
BEGIN CODE
Imports System.IO
Public Class Form1
Dim myline As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sr As New StreamReader("c:\test.txt", False)
myline = sr.ReadLine
TextBox1.Text = myline
sr.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tempstring As String
Dim result As DialogResult
If Not TextBox1.Text.Equals(myline) Then
result = MsgBox("Do you want to save changes", MsgBoxStyle.YesNo, "Save")
If result = Windows.Forms.DialogResult.Yes Then
Dim pass As String = InputBox("Enter the Password", "Admin", "")
If pass = "Password" Then
Dim sr As New StreamReader("c:\test.txt")
Dim sw As New StreamWriter("c:\Temp.txt")
While Not sr.EndOfStream
tempstring = sr.ReadLine()
If Not tempstring.Equals(myline) Then
sw.WriteLine(tempstring)
Else
sw.WriteLine(TextBox1.Text)
End If
End While
sw.Close()
sr.Close()
File.Delete("c:\test.txt")
Rename("c:\temp.txt", "c:\test.txt")
Else
MsgBox("Wrong Password")
Exit Sub
End If
End If
End If
End Sub
End Class
END CODE
I hope this will give you some idea to resolve your issue.
Regards,
Allen
Allen Smith
Software Engineer
ComponentOne LLC
www.componentone.com
|
|
|
|
|
hi guys
maskedtextbox1.mask = "##/##/####"
mskedtextbox2.mask = "##/##/####"
i am using maskedtextbox for getting i/p of date. i have taken mask properties short datetime. my data is stored in sql server 2005 where i have taken data type is varchar(10) in dd/mm/yyyy format (28/08/2007 & 31/08/2007).
my problem is that when i execute the sql query for the selected period in maskedtextbox it does not show correct data.
e.g.
sql_str = "insert mdate into xyz (select mdate from abc where " & _
"mdate between" & " '" &maskedtextbox1.text& "' and '"&mskedtextbox2.text&"'"
"and flag= '" & mflag & "')"
or using where condition it is not executing correct data.
can i get where i am wrong ? if is there any more suggestion for me suggest me.
Thanks
bye
|
|
|
|
|
As you are storing the dates as text, you can't do any calcualtions on them (including comparison). You could convert every value to a date in the query, but that's very inefficient.
Store the values as dates in the database, not text.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
hi
but it is working in vb6. so i think that it is possible in vb.net also. if i use dtpicker then is it possible ?
Thanks
bye
|
|
|
|
|
VB6 handles date/time differently than VB.NET and SQL Server. Who cares if it "used to work" under VB6 since you're not using it now.
You absolutely can NOT store dates in the database as strings and expect to be able to do comparisons and math on those dates, when they are not being treated as dates. Instead, they are treated no differently than if you stored "iwjf948fu04f" as your date.
Using a different control will have no effect since you are STILL storing dates as strings and not actualy datetime values in the database.
|
|
|
|
|
Change the data type of database columns to datetime and while storing and changing the values of that field try this statement for dates
Date.ParseExact(txtMasked.text,"Format")
format means "dd/mm/yyyy" i think it is in your case. the above statement will return a Date object which can be sent to database and then retrieved
Salman Sheikh
|
|
|
|
|
And you're telling me this why??
Yeah, but this doesn't solve the underlying problem of storing dates in the database as strings.
|
|
|
|
|
hi friends,
i developed a Vb.net2003 application & i have some crystal reports tooo. & i made i using default report options.. my porblem is i have some currency fields in the report which show the data with 2 decimal places.. but i want that in 3 decimal places..
anybody have any idea..
cheers..
|
|
|
|
|
Left Click on currency field and choose "Format Object" option, After that you saw a "Format Editor" dialog box and go to "Number" Tab.
Select "Custom Style" from Style listbox then click on "Customize..." button, After that you saw a "Custom Style" dialog box and go to "Number" Tab.
Select an option from "Decimals:" combox box that you want to show figures after decimal in currency value.
After the selection of your requirement the Decimals Combos value look like this:
Decimals: 1.000
By default currency field shows two (2) figures after decimal.
|
|
|
|
|
hi,
sorry to late reply... i already tried the method you mentioned.. & i was in research of that for last 2 - 3 days & atlast i found a small solution but big toooo....
sometimes the currency will show 2 decimals even we set the custum style.. so we have to convert that to string & display it.. so the solution is:
totext({fieldname},3,'','.')
if you want 4 decimal place , replace 3 to 4 , also comman (,) instead of dot(.) replace last ( '.' ) to ( ',' )
cheers..
|
|
|
|
|
I've built a VB.NET (VS8 2005) program, and I need it to put the program on Mac OSX (the machine is powerbook G4). I know it is possible with the use of Mono framework. But the setup and converting instruction is frustratingly unclear and confusing, or almost none; can anyone here tell me how to do this, please? Thank You.
Ryan
|
|
|
|
|
The .NET Framework is Microsoft's implementation of the Common Language Infrastructure standard. Mono is an open source project that also implements the CLI standard. Mono is modeled after the .NET Framework but is NOT a 100% compatible replacement for it. You cannot expect an app written under the .NET Framework to "just work" under Mono. The windowing system in Windows is not the same as on any Linux machine, therefor the entire System.Windows namespace in the .NET Framework's base class library cannot be expected to run under Linux. There is an implementation specific to Linux under the same namespace name (I think!) under Mono, but it works differently.
Your app will more than likely need modifications to make it work under Mono. What those modifications are cannot be documented because no documentation can predict what your code is going to do or how it will use Mono's base class library. It's a matter of compiling the app under Mono, see what errors it spits out and fixing the code.
|
|
|
|
|
You can also set up Mono on a Windows PC and do your testing there before you deploy to your Mac.
|
|
|
|
|
|
I have developed a simple VB 2005 Utility to Automate the backing up of express databases. Just provide me with a address to send it (I do not have a website) and I will send you the exe file with wizip. It reqires xp sp2 and .Net framework 2 to run.
Darcy Williamson
|
|
|
|
|
Nice...
You can just publish its code as an article.
|
|
|
|
|
Write up an article and submit it. Bear in mind that many people would probably not be eager to run an .exe that they don't know. With your article, send in the source code as well.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
|
I’m not a programmer or a formal student, rather I’m a 48 year old that loves to tinker, and has no programming experience per say. What I need is to know where to find VB6 examples of a program similar to what I have described below to teach me how to create my application in VB6. If none of them exist or are readily available, than I need some basics to get me started and figure out how to create my desired program using the basic examples provided with the hardware I’m working with.
I’m attempting to create a program that will allow me to use the data from sensors connected to an interface board (Phidgets 8/8/8) primarily pressure & oxygen sensors, and with the data I receive from the sensors I will use that information to control servos with the same interface based on preset values or ranges automatically. The Phidgets Interface Kit 8/8/8 comes with software examples / basic software interfaces written in VB6 so you can receive data and view sensor input changes which I’m doing now. It also makes available similar modest software to control the servos. My endeavor is to use the software / code examples provided in VB6 to create a more advanced program that will allow me to monitor, record / document, automate and control my device through the servos based on the sensor information.
Below are examples of the general interface code and the servo controller code provided with the hardware.
VB6 examples provided with the hardware:
' Program: InterfaceKit-Controller
' Author: Saul Greenberg
' Date: October, 2001
' Version: 1.0
' Description:
' - Gives a handy generic visual interface to the interface kit.
' - It displays the status of all analog and digital inputs
' and lets you turn on/off the outputs.
' - Its not actually that complex, as most of this just builds
' the visual interface. It is, after all, dealing with 20
' different inputs and outputs!
' - Note that you can adjust the min/max to increase/decrease the
' apparant sensitivity of the sensor (although it may get jittery
' if you stretch it too far)
Option Explicit
Dim WithEvents IFKit As PhidgetInterfaceKit
'''''''''''''''''''''''''''''''''''''''''''
''' User interface
'''''''''''''''''''''''''''''''''''''''''''
Private Sub Form_Load()
Set IFKit = New PhidgetInterfaceKit
IFKit.Open
'If (IFKit.IsAttached = False) Then
' MsgBox "Couldn't Connect to Interface Kit"
' Unload Form1
' End
'End If
End Sub
'Turn individual outputs on or off depending on which Output checkbox was selected
Private Sub chkOutputDigital_Click(Index As Integer)
If chkOutputDigital(Index).Value = 0 Then
IFKit.OutputState(Index) = False
chkOutputDigital(Index).BackColor = &H8000000F
Else
IFKit.OutputState(Index) = True
chkOutputDigital(Index).BackColor = vbRed
End If
End Sub
Private Sub IFKit_OnDetach()
DisplayProperties False
End Sub
Private Sub IFKit_OnAttach()
DisplayProperties True
End Sub
Private Sub IFKit_OnError(ByVal Description As String, ByVal SCODE As Long)
MsgBox "Error " & SCODE & ": " & Description
IFKit.Close
Unload Form1
End
End Sub
Private Sub RatioSelect_Click()
If RatioSelect.Value = 0 Then
IFKit.Ratiometric = False
Else
IFKit.Ratiometric = True
End If
End Sub
'Let the user set the sensitivity of the sensor reporting through a combo box
'i.e., a delta of the given amount must be seen before it will report it
Private Sub sensitivity_Click(Index As Integer)
If sensitivity.Item(Index).Caption = "Medium" Then
sensitivity.Item(Index).Caption = "High"
IFKit.SensorChangeTrigger(Index) = 1
ElseIf sensitivity.Item(Index).Caption = "High" Then
sensitivity.Item(Index).Caption = "Low"
IFKit.SensorChangeTrigger(Index) = 60
ElseIf sensitivity.Item(Index).Caption = "Low" Then
sensitivity.Item(Index).Caption = "Medium"
IFKit.SensorChangeTrigger(Index) = 10
End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''
''' Events generated by the Interface Kit
'''''''''''''''''''''''''''''''''''''''''''
'Report the value of the input whenever it changes
Private Sub IFKit_OnInputChange(ByVal Index As Long, ByVal NewState As Boolean)
If (Index >= lblInputDigital.Count) Then Exit Sub
If NewState Then
lblInputDigital(Index).Caption = "On"
Else
lblInputDigital(Index).Caption = "Off"
End If
End Sub
'Report the value of the sensor whenever it changes
Private Sub IFKit_OnSensorChange(ByVal Index As Long, ByVal SensorValue As Long)
If (Index >= sldrAnalog.Count) Then Exit Sub
sldrAnalog(Index).Value = SensorValue
lblAnalog(Index).Caption = SensorValue
End Sub
'''''''''''''''''''''''''''''''''''''''''''
''' Utility routines
'''''''''''''''''''''''''''''''''''''''''''
'Display the current properties of the IFKit in a label
Private Sub DisplayProperties(State As Boolean)
Dim i As Integer
lblProperties.Caption = ""
If State = False Then
Display "Detached"
Exit Sub
End If
Display "DeviceType: " & IFKit.DeviceType
Display "SerialNumber: " & IFKit.SerialNumber
Display "IsAttached: " & IFKit.IsAttached
Display "NumInputs: " & IFKit.NumInputs
Display "NumOutputs: " & IFKit.NumOutputs
Display "NumSensors: " & IFKit.NumSensors
Display ""
Display IFKit.LibraryVersion
End Sub
Private Sub Display(Line As String)
lblProperties.Caption = lblProperties.Caption & Line & vbCrLf
End Sub
Servo Slide Control Examples:
' Program: ServoSlider
' Author: Chester Fitchett
' Date: Feb 25, 2005
' Version: 1.0.2
' Description:
' -This example:
' o lets a user interactively adjust the angle of all motors through a slider
' o displays all the information it can about the PhidgetServo.
' o is somewhat robust about ignoring other Phidget servos that are attached
'
Option Explicit
Dim WithEvents Servo As PhidgetServo
Private Sub Form_Load()
Set Servo = New PhidgetServo
lblMessage.Caption = "Attach a PhidgetServo"
Frame1.Visible = False
sldrRotate.Min = -23
sldrRotate.Max = 231
sldrRotate.TickFrequency = 20
Servo.Open
End Sub
'SERVO ATTACHING
Private Sub Servo_OnAttach()
'Set up the slider
Frame1.Visible = True
sldrRotate.Value = 90
sldrRotate_Scroll 'Will rotate the motors to angle 0
'Show the current Servo information
lblMessage.Caption = "PhidgetServo Attached"
lblNumMotors.Caption = Servo.NumMotors
lblSerialNumber.Caption = Servo.SerialNumber
End Sub
Private Sub Servo_OnDetach()
'Show the current Servo information
lblMessage.Caption = "Attach a PhidgetServo "
lblNumMotors.Caption = ""
lblSerialNumber.Caption = ""
lblAngle.Caption = ""
Frame1.Visible = False
End Sub
Private Sub sldrRotate_Scroll()
Dim Index As Long
For Index = 0 To Servo.NumMotors - 1
Servo.MotorPosition(Index) = sldrRotate.Value
lblAngle.Caption = Servo.MotorPosition(Index)
Next Index
End Sub
|
|
|
|
|
Best to dump VB6 since it is not supported anymore.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Probably the best place to look for examples would be the manufacturers website. I took a quick look at it and they have a forum where you can ask questions. You could try google but many of the examples are probably not going to be usefull if they are not for your particular package since they won't be using the phidgets api.
Speaking as a self taught programmer myself, here would be my advice. I would say that trying to learn by osmosis (looking at code examples) is not the best way, you need to learn a few basic concepts which I will list below. Most of these basic elements will occur in any program regardless of what it does. The thing that differentiates programs is less the basic elements you use but rather how they are combined. I would advise going to the library and getting a vb book or at least looking up these terms on the internet.
1) What are variables and arrays and what is variable scope?
2) What are subs/functions/methods and events? What are arguments/parameters? What is the difference between passing by value and passing by reference?
3) What are conditional statements (ie if then else elseif ect...)
4) What are loops (both for next and do loops)?
5) What do the commands NOT, AND, OR, and XOR mean?
6) How to write mathmatical expressions and how to write strings?
7) What are modules?
Finally you need to learn how to use the program itself, how to drop controls onto a form, and sometimes overlooked how to use the debugging tools (ie breakpoints, stepping through ect...)
There are many other items I could have added but those are definately the most important commands and are central to virtually every program. Once you learn them you should be able to write some simple programs and understand alot of the code and documentation that comes with your kit.
One last thing; although vb6 may be a tad easier to use it is going to be harder to find code examples for it because it was replaced by vb.net some years ago, you might want to consider switching. If you do you can download the express version for free off microsoft's website.
|
|
|
|
|