要求将集装箱信息(集装箱名称、尺寸、最大容重的数据)
写成指定格式的二进制文件。
集装箱信息 共66字节,
其中:
集装箱名 字符串 50字节 (需用’\0’结尾,故请注意最大长度)
集装箱L int 4字节
集装箱W int 4字节
集装箱H int 4字节
集装箱容重 int 4字节
17 个解决方案
#1
你把字符转换成UNICODE码后转换成2进制然后写进2进制文件里
#2
Private Type Container
Container_Name As String * 48
Container_Length As Integer
Container_Width As Integer
Container_Height As Integer
Container_Weight As Integer
End Type
Private Function SaveDataToFile(ByVal strFile As String, tData As Container) As Boolean
Dim lFN As Long, lFL As Long
On Error GoTo Err1
lFN = FreeFile
SaveDataToFile = False
Open strFile For Binary As #lFN
lFL = LOF(lFN)
Put #lFN, lFL + 1, tData
Close #lFN
SaveDataToFile = True
Exit Function
Err1:
Close #lFN
End Function
Private Function GetDataFromFile(ByVal strFile As String, tData() As Container) As Boolean
Dim lFN As Long, lFL As Long, lNum As Long, tD As Container
On Error GoTo Err1
lFN = FreeFile
lNum = 1
GetDataFromFile = False
Open strFile For Random As #lFN Len = Len(tD)
Do Until EOF(lFN)
Get #lFN, lNum, tD
ReDim Preserve tData(lNum) As Container
If Trim(tD.Container_Name) <> "" And tD.Container_Length <> 0 Then
tData(lNum) = tD
End If
lNum = lNum + 1
Loop
Close #lFN
GetDataFromFile = True
Exit Function
Err1:
Close #lFN
End Function
Container_Name As String * 48
Container_Length As Integer
Container_Width As Integer
Container_Height As Integer
Container_Weight As Integer
End Type
Private Function SaveDataToFile(ByVal strFile As String, tData As Container) As Boolean
Dim lFN As Long, lFL As Long
On Error GoTo Err1
lFN = FreeFile
SaveDataToFile = False
Open strFile For Binary As #lFN
lFL = LOF(lFN)
Put #lFN, lFL + 1, tData
Close #lFN
SaveDataToFile = True
Exit Function
Err1:
Close #lFN
End Function
Private Function GetDataFromFile(ByVal strFile As String, tData() As Container) As Boolean
Dim lFN As Long, lFL As Long, lNum As Long, tD As Container
On Error GoTo Err1
lFN = FreeFile
lNum = 1
GetDataFromFile = False
Open strFile For Random As #lFN Len = Len(tD)
Do Until EOF(lFN)
Get #lFN, lNum, tD
ReDim Preserve tData(lNum) As Container
If Trim(tD.Container_Name) <> "" And tD.Container_Length <> 0 Then
tData(lNum) = tD
End If
lNum = lNum + 1
Loop
Close #lFN
GetDataFromFile = True
Exit Function
Err1:
Close #lFN
End Function
#3
记住!
Container_Name的值要加上"\0"哦!
Container_Name的值要加上"\0"哦!
#4
不好意思!
代码改一下!
Private Type Container
Container_Name As String * 50'<--------------------
Container_Length As Integer
Container_Width As Integer
Container_Height As Integer
Container_Weight As Integer
End Type
代码改一下!
Private Type Container
Container_Name As String * 50'<--------------------
Container_Length As Integer
Container_Width As Integer
Container_Height As Integer
Container_Weight As Integer
End Type
#5
up
#6
应该怎么调用这个函数
SaveDataToFile ???
^_^。
SaveDataToFile ???
^_^。
#7
Private Sub Command1_Click()
Dim tD As Container
With tD
.Container_Name = "Name\0"
.Container_Length = 20
.Container_Height = 5
.Container_Width = 4
.Container_Weight = 10
End With
Call SaveDataToFile("C:\ttt.txt", tD)
End Sub
Dim tD As Container
With tD
.Container_Name = "Name\0"
.Container_Length = 20
.Container_Height = 5
.Container_Width = 4
.Container_Weight = 10
End With
Call SaveDataToFile("C:\ttt.txt", tD)
End Sub
#8
我把你前面的代码做成控件
然后在asp里这样调用:
Dim tD As Container
With tD
.Container_Name = "集装箱1"
.Container_Length = 200
.Container_Height = 300
.Container_Width = 400
.Container_Weight = 500
End With
Call SaveDataToFile("d:\aa.txt", tD)
可是有提示错误:
语句未结束
/test1.asp, line 25, column 7
Dim tD As Container
------^
然后在asp里这样调用:
Dim tD As Container
With tD
.Container_Name = "集装箱1"
.Container_Length = 200
.Container_Height = 300
.Container_Width = 400
.Container_Weight = 500
End With
Call SaveDataToFile("d:\aa.txt", tD)
可是有提示错误:
语句未结束
/test1.asp, line 25, column 7
Dim tD As Container
------^
#9
当然在前面我已经引用了的
set dllobj = server.CreateObject("gm.gmrw")
set dllobj = server.CreateObject("gm.gmrw")
#10
老兄!
你早说是在Asp中嘛!我还以为你在VB中呢?
在Asp中不能直接实现对文件的二进制操作。要写一个ActiveX组建!
如果需要,EMail给我!Rick110A@yahoo.com.cn 我帮你写一个!
你早说是在Asp中嘛!我还以为你在VB中呢?
在Asp中不能直接实现对文件的二进制操作。要写一个ActiveX组建!
如果需要,EMail给我!Rick110A@yahoo.com.cn 我帮你写一个!
#11
好的。我马上写邮件给你
#12
好的。我已经发给你了
#13
一个.qxm文件存一个集装箱数据吗?
#14
一个.qxm文件存所有的数据,你看到邮件中的附件了吗?
后来发的邮件有附件的。
后来发的邮件有附件的。
#15
你有msn吗?在线交流、
#16
没有!QQ怎么样?
#17
QQ=69320713
#1
你把字符转换成UNICODE码后转换成2进制然后写进2进制文件里
#2
Private Type Container
Container_Name As String * 48
Container_Length As Integer
Container_Width As Integer
Container_Height As Integer
Container_Weight As Integer
End Type
Private Function SaveDataToFile(ByVal strFile As String, tData As Container) As Boolean
Dim lFN As Long, lFL As Long
On Error GoTo Err1
lFN = FreeFile
SaveDataToFile = False
Open strFile For Binary As #lFN
lFL = LOF(lFN)
Put #lFN, lFL + 1, tData
Close #lFN
SaveDataToFile = True
Exit Function
Err1:
Close #lFN
End Function
Private Function GetDataFromFile(ByVal strFile As String, tData() As Container) As Boolean
Dim lFN As Long, lFL As Long, lNum As Long, tD As Container
On Error GoTo Err1
lFN = FreeFile
lNum = 1
GetDataFromFile = False
Open strFile For Random As #lFN Len = Len(tD)
Do Until EOF(lFN)
Get #lFN, lNum, tD
ReDim Preserve tData(lNum) As Container
If Trim(tD.Container_Name) <> "" And tD.Container_Length <> 0 Then
tData(lNum) = tD
End If
lNum = lNum + 1
Loop
Close #lFN
GetDataFromFile = True
Exit Function
Err1:
Close #lFN
End Function
Container_Name As String * 48
Container_Length As Integer
Container_Width As Integer
Container_Height As Integer
Container_Weight As Integer
End Type
Private Function SaveDataToFile(ByVal strFile As String, tData As Container) As Boolean
Dim lFN As Long, lFL As Long
On Error GoTo Err1
lFN = FreeFile
SaveDataToFile = False
Open strFile For Binary As #lFN
lFL = LOF(lFN)
Put #lFN, lFL + 1, tData
Close #lFN
SaveDataToFile = True
Exit Function
Err1:
Close #lFN
End Function
Private Function GetDataFromFile(ByVal strFile As String, tData() As Container) As Boolean
Dim lFN As Long, lFL As Long, lNum As Long, tD As Container
On Error GoTo Err1
lFN = FreeFile
lNum = 1
GetDataFromFile = False
Open strFile For Random As #lFN Len = Len(tD)
Do Until EOF(lFN)
Get #lFN, lNum, tD
ReDim Preserve tData(lNum) As Container
If Trim(tD.Container_Name) <> "" And tD.Container_Length <> 0 Then
tData(lNum) = tD
End If
lNum = lNum + 1
Loop
Close #lFN
GetDataFromFile = True
Exit Function
Err1:
Close #lFN
End Function
#3
记住!
Container_Name的值要加上"\0"哦!
Container_Name的值要加上"\0"哦!
#4
不好意思!
代码改一下!
Private Type Container
Container_Name As String * 50'<--------------------
Container_Length As Integer
Container_Width As Integer
Container_Height As Integer
Container_Weight As Integer
End Type
代码改一下!
Private Type Container
Container_Name As String * 50'<--------------------
Container_Length As Integer
Container_Width As Integer
Container_Height As Integer
Container_Weight As Integer
End Type
#5
up
#6
应该怎么调用这个函数
SaveDataToFile ???
^_^。
SaveDataToFile ???
^_^。
#7
Private Sub Command1_Click()
Dim tD As Container
With tD
.Container_Name = "Name\0"
.Container_Length = 20
.Container_Height = 5
.Container_Width = 4
.Container_Weight = 10
End With
Call SaveDataToFile("C:\ttt.txt", tD)
End Sub
Dim tD As Container
With tD
.Container_Name = "Name\0"
.Container_Length = 20
.Container_Height = 5
.Container_Width = 4
.Container_Weight = 10
End With
Call SaveDataToFile("C:\ttt.txt", tD)
End Sub
#8
我把你前面的代码做成控件
然后在asp里这样调用:
Dim tD As Container
With tD
.Container_Name = "集装箱1"
.Container_Length = 200
.Container_Height = 300
.Container_Width = 400
.Container_Weight = 500
End With
Call SaveDataToFile("d:\aa.txt", tD)
可是有提示错误:
语句未结束
/test1.asp, line 25, column 7
Dim tD As Container
------^
然后在asp里这样调用:
Dim tD As Container
With tD
.Container_Name = "集装箱1"
.Container_Length = 200
.Container_Height = 300
.Container_Width = 400
.Container_Weight = 500
End With
Call SaveDataToFile("d:\aa.txt", tD)
可是有提示错误:
语句未结束
/test1.asp, line 25, column 7
Dim tD As Container
------^
#9
当然在前面我已经引用了的
set dllobj = server.CreateObject("gm.gmrw")
set dllobj = server.CreateObject("gm.gmrw")
#10
老兄!
你早说是在Asp中嘛!我还以为你在VB中呢?
在Asp中不能直接实现对文件的二进制操作。要写一个ActiveX组建!
如果需要,EMail给我!Rick110A@yahoo.com.cn 我帮你写一个!
你早说是在Asp中嘛!我还以为你在VB中呢?
在Asp中不能直接实现对文件的二进制操作。要写一个ActiveX组建!
如果需要,EMail给我!Rick110A@yahoo.com.cn 我帮你写一个!
#11
好的。我马上写邮件给你
#12
好的。我已经发给你了
#13
一个.qxm文件存一个集装箱数据吗?
#14
一个.qxm文件存所有的数据,你看到邮件中的附件了吗?
后来发的邮件有附件的。
后来发的邮件有附件的。
#15
你有msn吗?在线交流、
#16
没有!QQ怎么样?
#17
QQ=69320713