阅读:1896回复:3
[求助]请问可以通过编程实现对dbf文件某个属性字段下的值的修改吗?
请问可以通过编程实现对dbf文件某个属性字段下的值的修改吗?如果可以,请问如何实现?谢谢!
|
|
1楼#
发布于:2006-10-15 09:44
<P>Private editbufr As Variant<BR>Private recset As MapObjects2.Recordset<BR>Private TotalRecs As Integer</P>
<P>Private Sub Combo1_Click()<BR> Text1.Text = recset.Fields(Combo1.List(Combo1.ListIndex)).Value<BR>End Sub</P> <P>Private Sub Command1_Click(Index As Integer)<BR> Static recnum</P> <P> With recset.Fields(Combo1.List(Combo1.ListIndex))<BR> Select Case Index<BR> Case 0 'Next<BR> If recnum < TotalRecs Then<BR> recset.MoveNext<BR> Text1.Text = .Value<BR> recnum = recnum + 1</P> <P> Command1(1).Enabled = True<BR> If recnum = TotalRecs - 1 Then<BR> Command1(0).Enabled = False<BR> Else<BR> Command1(0).Enabled = True<BR> End If<BR> Map1.TrackingLayer.Refresh True<BR> End If<BR> Case 1 'Previous<BR> If recnum > 0 Then<BR> recset.MovePrevious<BR> Text1.Text = .Value<BR> recnum = recnum - 1<BR> Command1(0).Enabled = True<BR> If recnum = 0 Then<BR> Command1(1).Enabled = False</P> <P> Else<BR> Command1(1).Enabled = True<BR> End If<BR> Map1.TrackingLayer.Refresh True<BR> End If<BR> Case 2 'Change<BR> editbufr = .Value<BR> recset.Edit<BR> .Value = Text1.Text<BR> resp$ = MsgBox("Are you sure you want to change the value?", vbYesNo + vbInformation, "MapObjects")<BR> If resp$ = vbYes Then<BR> GetEditMode 'demonstrates EditMode property<BR> recset.Update<BR> GetEditMode<BR> Else</P> <P> recset.CancelUpdate<BR> Text1.Text = editbufr<BR> End If<BR> recset.StopEditing<BR> End Select<BR> End With<BR>End Sub</P> <P>Sub GetEditMode()<BR> Static Demonstrated As Integer<BR> If Demonstrated < 2 Then<BR> Select Case recset.EditMode<BR> Case 0<BR> Msg$ = "No editing operation is in progress."<BR> Button$ = vbInformation<BR> Case 1<BR> Msg$ = "Edit in progress"<BR> Button$ = vbExclamation<BR> Case 2<BR> Msg$ = "AddNew method has been invoked."</P> <P> Button$ = vbExclamation<BR> End Select<BR> MsgBox Msg$, Button$, "MapObjects"<BR> End If<BR> Demonstrated = Demonstrated + 1<BR>End Sub</P> <P>Private Sub Form_Load()<BR> <BR> For i = 1 To 2 ' Create two more instances of Command1.<BR> ' Set the location of the new option button.<BR> Load Command1(i)<BR> Command1(i).Top = Command1(i - 1).Top + Command1(0).Height + 40<BR> Command1(i).Visible = True<BR> Next i</P> <P> Command1(0).Caption = "Next"<BR> Command1(1).Caption = "Previous"</P> <P> Command1(2).Caption = "Change"<BR> <BR>Call Loadlayer<BR> <BR> Set recset = Map1.Layers(0).Records<BR> For Each f In recset.Fields<BR> Combo1.AddItem f.Name<BR> Next f<BR> Combo1.ListIndex = 0<BR> <BR> 'count the number of records<BR> ctr = 0<BR> Do While Not recset.EOF<BR> TotalRecs = TotalRecs + 1<BR> recset.MoveNext<BR> Loop</P> <P> recset.MoveFirst<BR> Text1.Text = recset.Fields(Combo1.List(Combo1.ListIndex)).Value<BR> Command1(1).Enabled = False<BR> If Not recset.Updatable Then<BR> Command1(2).Enabled = False</P> <P> End If<BR>End Sub</P> <P>Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As Stdole.OLE_HANDLE)<BR> Map1.FlashShape recset.Fields("Shape").Value, 3<BR>End Sub</P> |
|
2楼#
发布于:2007-03-29 21:12
<P>上面的那个源代码是帮助里的吧,有很多错误</P>
<P>我都试过很多次了,能不能麻烦您给修一下再发</P> |
|
3楼#
发布于:2007-03-31 14:01
<P>呵呵,我已经解决了上面的问题</P>
<P>QQ309116862</P> |
|