积极答复者
怎么把窗体中的坐标值存入数据库或者文档?

问题
-
怎么把窗体中的坐标值存入数据库或者文档?数据库或文档
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim t As Single
Try
t = DirectCast(sender, System.Windows.Forms.TextBox).Text
x = t
Catch
End Try
Me.Invalidate()
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
Dim t As Single
Try
t = DirectCast(sender, System.Windows.Forms.TextBox).Text
y = t
Catch
End Try
Me.Invalidate()
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim x As Integer
Dim y As Integer
Dim rect As Rectangle = Rectangle.FromLTRB(x - 4, y - 4, x + 4, y + 4)
e.Graphics.DrawEllipse(SystemPens.ControlText, rect)
e.Graphics.FillEllipse(SystemBrushes.ControlText, rect)
End Sub
End Class
x和y值由两个文本框输入
画出点的坐标为(x,y),怎样把(x,y)坐标值存入文档?(比方说text或者Excel)
如果在存入数据库,容易不容易实现?
visual studio 2003
答案
-
- 已标记为答案 KeFang Chen 2009年3月9日 8:32
-
可以把x和y 用 binarywriter 写到一个内存流 然后把流的 toarray 当成image 或者binary(max) 写入一行中
读取的时候 用binaryreader
一个点一行实在太奢侈了
就算首页不能显示30天内排行榜 回答总数也快接近top10了 5555
努力奋斗 重回首页排行榜!!! 55555
有原则的回答问题: 不懂的不去装懂,别人回答得很完整的,没有需要补充的不去蹭分。- 已标记为答案 KeFang Chen 2009年3月9日 8:32
全部回复
-
- 已标记为答案 KeFang Chen 2009年3月9日 8:32
-
可以把x和y 用 binarywriter 写到一个内存流 然后把流的 toarray 当成image 或者binary(max) 写入一行中
读取的时候 用binaryreader
一个点一行实在太奢侈了
就算首页不能显示30天内排行榜 回答总数也快接近top10了 5555
努力奋斗 重回首页排行榜!!! 55555
有原则的回答问题: 不懂的不去装懂,别人回答得很完整的,没有需要补充的不去蹭分。- 已标记为答案 KeFang Chen 2009年3月9日 8:32
-
如果你有一个数组 里面都是point
Dim pts As Point()
Dim sm As New IO.MemoryStream() Dim sr As New IO.BinaryWriter(sm) For Each p As Point In pssr.Write(p.X)
sr.Write(p.Y)
Next
sm.ToArray() 就是你要的数据
用完了别忘记关闭sm哦
读取的时候用同样的方法/binreader 读取 stream 就好了
就算首页不能显示30天内排行榜 回答总数也快接近top10了 5555
努力奋斗 重回首页排行榜!!! 55555
有原则的回答问题: 不懂的不去装懂,别人回答得很完整的,没有需要补充的不去蹭分。 -
韦恩卑鄙 说:
如果你有一个数组 里面都是point
Dim pts As Point()
Dim sm As New IO.MemoryStream()
Dim sr As New IO.BinaryWriter(sm)
For Each p As Point In ps
sr.Write(p.X)
sr.Write(p.Y)
Next
sm.ToArray() 就是你要的数据
用完了别忘记关闭sm哦
读取的时候用同样的方法/binreader 读取 stream 就好了
就算首页不能显示30天内排行榜 回答总数也快接近top10了 5555
努力奋斗 重回首页排行榜!!! 55555
有原则的回答问题: 不懂的不去装懂,别人回答得很完整的,没有需要补充的不去蹭分。
没有弄明白,Dim pts As Point() 没用到。也没有把文本放入***.txt。
visual studio 2008 -
feiyun0112 说:
Form1_Paint里保存到txt,一行保存一个点
http://support.microsoft.com/kb/315828
http://feiyun0112.cnblogs.com/
Imports System.IO
Module Module1
Sub main()
Dim objStreamWriter As StreamWriter'Pass the file path and the file name to the StreamWriter constructor.
objStreamWriter = New StreamWriter("D:\Test.txt")'Write a line of text.
objStreamWriter.WriteLine("Hello World")'Write a second line of text.
objStreamWriter.WriteLine("From the StreamWriter class")'Close the file.
objStreamWriter.Close()
End Sub
End Module
我怎么在D盘没有看到Test.txt??
visual studio 2008 -
没问题呀,你跟中看看,或者这样
'Close the file.
objStreamWriter.Flush()
objStreamWriter.Close()
http://feiyun0112.cnblogs.com/ -
feiyun0112 说:
没问题呀,你跟中看看,或者这样
'Close the file.
objStreamWriter.Flush()
objStreamWriter.Close()
http://feiyun0112.cnblogs.com/
确实没有,不知道出了什么问题?我在想想。Sub main()是放在Module Module1中的啊?
visual studio 2008 -
feiyun0112 说:
没问题呀,你跟中看看,或者这样
'Close the file.
objStreamWriter.Flush()
objStreamWriter.Close()
http://feiyun0112.cnblogs.com/
确实没有,你能不能把你的代码全部贴出来给我看看。
讲下你做的过程
visual studio 2008 -
liunain021 说:feiyun0112 说:
没问题呀,你跟中看看,或者这样
'Close the file.
objStreamWriter.Flush()
objStreamWriter.Close()
http://feiyun0112.cnblogs.com/
确实没有,你能不能把你的代码全部贴出来给我看看。
讲下你做的过程
visual studio 2008
你跟中运行,代码执行了吗?
只有控制台程序才有Sub Main, 你看看项目属性的启动窗体
http://feiyun0112.cnblogs.com/